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

December 3, 2019 123 views
Nginx

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
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
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?

2 Answers

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

Hello,

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:

https://www.digitalocean.com/community/questions/how-to-troubleshoot-common-nginx-issues-on-linux-server?answer=56476

Hope that this helps!
Regards,
Bobby

Have another answer? Share your knowledge.

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