Question

Error 502 Bad Gateway nginx/1.14.0 (Ubuntu)

Hello!! I upload my website to mi hosting with ubuntu but when I enter in my site, it show me this error but I don´t know what could be the reason. When I eject /var/log/nginx/error.log says me PERMISSION DENIED sudo nginx -t–> nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful I checked whether nginx is running systemctl status nginx: ● nginx.service - A high performance web server and a reverse proxy serv Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor pr Drop-In: /etc/systemd/system/nginx.service.d └─override.conf Active: active (running) since Fri 2020-10-30 03:34:28 UTC; 1h 12min Docs: man:nginx(8) Process: 964 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCE Process: 960 ExecStart=/usr/sbin/nginx -g daemon on; master_process on Process: 897 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_p Main PID: 963 (nginx) Tasks: 2 (limit: 2361) CGroup: /system.slice/nginx.service ├─963 nginx: master process /usr/sbin/nginx -g daemon on; mas └─966 nginx: worker process

checked whether nginx is running systemctl status nginx:

● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-10-23 19:01:12 UTC; 6 days ago Docs: man:nginx(8) Process: 24459 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) Process: 24462 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 24461 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 24464 (nginx) Tasks: 2 (limit: 614) CGroup: /system.slice/nginx.service ├─24464 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; └─24465 nginx: worker process

Oct 23 19:01:12 wooplance-server1.com systemd[1]: Stopped A high performance web server and a reverse proxy server. Oct 23 19:01:12 wooplance-server1.com systemd[1]: Starting A high performance web server and a reverse proxy server… Oct 23 19:01:12 wooplance-server1.com systemd[1]: Started A high performance web server and a reverse proxy server.

Running ufw status gives:

Status: active

To Action From


22/tcp ALLOW Anywhere 80/tcp ALLOW Anywhere Nginx HTTP ALLOW Anywhere 22/tcp (v6) ALLOW Anywhere (v6) 80/tcp (v6) ALLOW Anywhere (v6) Nginx HTTP (v6) ALLOW Anywhere (v6)

And /etc/nginx/nginx.conf gives me:

Permission Denied

Subscribe
Share

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

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.

Hi there,

The reason you are getting Permission Denied is probably because of your user permissions. This occurs when you are trying to execute a file which you do not have the permissions to. If you haven’t set up a superuser, just follow this DigitalOcean tutorial on how to do that:

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-20-04

Also, I would recommend you check out this video on Fixing 502 Bad Gateway Nginx as it may come in handy.

Let me know how it goes.

Regards, Boyan