Using authbind to run node.js on port 80 with Dreamhost

Like everything else this requires a Dreamhost VPS. If you don’t have node.js installed yet checkout my slightly outdated guide on installing node.js on Dreamhost. It should still work just swap out the version of node.js that you need. You will also need to turn off or change the port of the web server of the VPS.

It’s a general rule that you shouldn’t run node as root, but only root can bind to ports less than 1024. This is where authbind comes in. Authbind allows non-root users to bind to ports less than 1024. Hers how:

  1. SSH into your VPS as your shell user and su into your admin account.

  2. Install authbind with sudo apt-get install authbind

  3. Configure authbind. Just swap out user with your shell user that the site runs on.

    sudo touch /etc/authbind/byport/80
    sudo chown user /etc/authbind/byport/80
    sudo chmod 755 /etc/authbind/byport/80
  4. Exit the admin user exit. You should now be your shell user.

  5. Configure your node app to run on port 80. In this example we will use the hello world example from modified to run on port 80. Save it as app.js.

    var http = require('http');
    http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('Hello World\n');
    console.log('Server running on port 80');
  6. Run node with authbind node app.js

****Update: Want to run forever with authbind? Checkout Using authbind with forever



  1. sterlingrules reblogged this from respectthecode and added:
    advertised. But, is there a way
  2. respectthecode posted this
Mobile Analytics