Question

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

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)

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?

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.

Accepted Answer

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

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.

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