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.

Bobby Iliev
Site Moderator
Site Moderator badge
December 3, 2019

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.