Running on your workstation
As a general rule, processes running without root privileges cannot bind to ports below 1024.
So try a higher port, or run with elevated privileges via sudo
. You can downgrade privileges after you have bound to the low port using process.setgid
and process.setuid
.
Running on heroku
When running your apps on heroku you have to use the port as specified in the PORT environment variable.
See http://devcenter.heroku.com/articles/node-js
const server = require('http').createServer();
const port = process.env.PORT || 3000;
server.listen(port, () => console.log(`Listening on ${port}`));