What happened to my permissions and how do I fix them? NGINX 502 error.

Posted December 3, 2019 7.7k views

I set up my site a while ago so I kind of forget what I did. But it used to run just fine, and now I can’t access it, I just get a 502. This server is Ubuntu 18, with nginx and node.

First problem was that the server reset and cleared out my pm2 service which started the server. I started it again, but still get a 502. I can see that the server starts and doesn’t crash in the pm2 logs.

Then I tried to restart nginx, and got this:

myusername@myusername:~/web$ service nginx start
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'nginx.service'.
Authenticating as: myusername
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
Failed to start nginx.service: Access denied
See system logs and 'systemctl status nginx.service' for details.

I don’t remember setting up this password and don’t have it written down. Though I then did sudo service nginx start and it didn’t seem to have a problem. Though it still has a 502.

I also tested the nginx config (though it was working before and I haven’t changed anything)

samkeddy@samkeddy:~/web$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Any other ideas to get my site back online?

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

I found the problem, it was getting port 8080 from the process.env somehow, and I was using port 3000.


I could suggest using sudo to run your Nginx start command:

sudo service nginx start

Let me know how that goes!

I could also suggest having a look at this article on how to troubleshoot common Nginx problems:

Hope that this helps!