Deploying a Node.js application
on Passenger Standalone

This guide teaches you how you can deploy your app to a server. This guide assumes that you have already done the following, and that you know how to do them:

  • Passenger is already installed on the server.
  • You have already transferred the application's code to the server.
  • You have already installed Node.js.
  • You have already installed all necessary dependencies that your application needs.

If you miss one of these prerequisites or don't know how to perform it, then we recommend you to follow the Deployment tutorial. The deployment tutorial is end-to-end guide and teaches you how to install every component.

Table of contents

  • Loading...

Step 1: create a Passenger config file

Since this is a production environment, we need to customize Passenger a little bit. Create a file named Passengerfile.json in your application's directory:

  // Tell Passenger that this is a Node.js app.
  // Replace "app.js" with your app's entry point file.
  "app_type": "node",
  "startup_file": "app.js",
  // Run the app in a production environment. The default value is "development".
  "environment": "production",
  // Run Passenger on the given port. In this example, we use port 80,
  // the standard HTTP port.
  "port": 80,
  // Tell Passenger to daemonize into the background.
  "daemonize": true,
  // Tell Passenger to run the app as the given user. Only has effect
  // if Passenger was started with root privileges.
  "user": "myappuser"

In the above configuration example, we instructed Passenger to run on port 80. If you don't already have a server running on port 80, then leave it at 80 so that Passenger listens on the default HTTP port directly (which is safe).

But if you already have a web server running on port 80, then you may be interested in installing Passenger Standalone behind that web server through a reverse proxy. We'll cover that later. For now, specify a random unused port that is not 80.


  • Replace myappuser with the name of the user account that you wish to run your app under.

When you are done with all this, commit this file to version control and transfer it to your server.

Step 2: start Passenger Standalone

While in your application's code directory, start Passenger. As configured, Passenger will daemonize into the background.

The reason why we prefix the command with sudo is because, in the Passengerfile.json example, we configured Passenger to listen on port 80. Only root privileged processes can listen on ports lower than 1024. If in the previous step you did not configure port 80, then you do not have to prefix the command with sudo.

$ cd /path-to-your-app
$ sudo passenger start

Step 3: install reverse proxy (if applicable)

Did you configure Passenger on port 80 in step 1? If so, then you can skip to step 4.

Did you choose to configure Passenger on another port? Then please read Putting Passenger Standalone behind an Nginx or Apache reverse proxy.

Step 4: make sure Passenger Standalone starts on system boot

Passenger is now running and serving your app, but that only lasts until you reboot your server. So you must configure your server to start Passenger Standalone on system boot.

The easiest way to do that is to add it to the file /etc/rc.local. This script is called during system boot. Ensure that it's executable and open it in a text editor:

$ sudo chmod +x /etc/rc.local
$ sudo nano /etc/rc.local

Here is an example of what you may want to add to /etc/rc.local. If there is an exit command in rc.local, make sure you add these before the exit command.

# Change working directory to your webapp.
cd /path-to-your-app

# Start Passenger Standalone in daemonized mode. Passenger will be started as
# root when run from this file, but Passengerfile.json tells it to drop its
# privileges to a normal user.
passenger start