Rails.service (code=exited, status=1/FAILURE) / BAD GATEWAY 502 when starting

Posted April 12, 2021 79 views
Ruby on Rails

I created a rails 6 droplet (ubuntu 20.04) and deployed my app but I can’t get it to run

I’ve edited /etc/nginx/sites-available/rails to:

root /home/my_app/public;

nano /etc/systemd/system/rails.service to:


When I run systemctl status rails it shows

● rails.service - ExampleApp
     Loaded: loaded (/etc/systemd/system/rails.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2021-04-12 09:07:40 UTC; 2s ago
    Process: 60004 ExecStart=/bin/bash -lc bundle exec puma (code=exited, status=1/FAILURE)
   Main PID: 60004 (code=exited, status=1/FAILURE)

Nginx seems to be running, I’ve done daemon-reload, restarted nginx/rails.service

I’m not sure where to go from here

Any help would be appreciated!

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.

Submit an Answer
2 answers

It seems that my ‘rails’ user role didn’t have proper permissions so a quick chown fixed it!

Hi @insanelybor3d,

I’m glad to hear you were able to fix the issue! Having said that, in case someone else finds this answer I’ll give the most common things one can check.

In cases like this, one of the crucial things you need to check is your service’s error log. Most commonly, the log files are located in /var/log/. Having said that if you are not aware, you can always do a quick google search and it will show it right away.

Inside the Error Log file, you’ll see the exact reason behind the error you are experiencing. From there can be endless possibilities. In this case, the issue was ownership, it might be permissions, it might be some typo in a configuration file. All I mean is it can be anything but checking the Log file should be the first way to go.