Why do I have to manually start a passenger instance for nginx sub domain to see my app?

I have a rails api app and a static react front-end app and I have been trying to get the rails app to run on a subdomain for over 24 hrs now. I got it all hooked up yesterday and ended with a 302 bad gateway error, I got back to it this morning and did a number of things including changing the owner of the app files and finally tried manually starting a passenger instance which worked.

I have another rails app deployed on another droplet and it doesn’t seem to need me to manually start passenger, why is it that for my api I need to do so?

Here is the config files in case someone has a better way to set all of this up:

upstream app_server { server fail_timeout=0; }

server {
    listen   80;
    root /var/www/my-rails-app/public;
#    index index.htm index.html;

    passenger_enabled on;
    passenger_ruby /usr/local/rvm/gems/ruby-2.6.4/wrappers/ruby;

    passenger_env_var POSTGRES_USER 'database_username';
    passenger_env_var POSTGRES_PASSWORD 'database_password';
    passenger_env_var POSTGRES_HOST 'localhost';
    passenger_env_var POSTGRES_DB 'database_name';
    passenger_env_var SECRET_KEY_BASE secret_key;

    location / {
        try_files $uri/index.html $uri.html $uri @app;

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
                    try_files $uri @app;

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;

server {
    listen   80;
    root /var/www/my-rails-app/client/build;
    index index.htm index.html;

    location / {
        try_files $uri $uri/ =404;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;

I finally got the app to run with this config once I cd’d into my app folder and manually started passenger using this command:

passenger start -a -p 8080 -d -e production

Any Idea why that was necessary when it’s not necessary on my other rails app? Is there a better way to do this?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


Passenger checks whether the virtual host is a Passenger-supported application. If it fails then Passenger will let Nginx serve the virtual host root as if Passenger is not activated.

The good thing is that you could override the autodetection so that it matches your needs.

For more information I would recommend going through the documentation here:

Regards, Bobby