502 Bad Gateway nginx/1.16.0 after reboot

April 30, 2019 2k views


I was configuring the email server, then rebooted the server and now Im getting error 502 Bad Gateway nginx/1.16.0

What can I look for?


1 comment
5 Answers


This typically indicates that a back-end service is not listening, which Nginx is relying on to serve the content. This could be anything from PHP-FPM to a Node.js app. Though I can’t say which it is without seeing the logs, I can say that starting that service manually will likely resolve the issue. If your service uses systemd, it can be made to start on boot. For example, if the server were named “php-fpm” I could run:

systemctl enable php-fpm


  • [root@pf1 ~]# systemctl enable php-fpm
    Failed to execute operation: No such file or directory

/var/log/nginx/error.log exist but it is empty.

Is it maybe writing on another location?

[root@pf1 ~]# service nginx status
Redirecting to /bin/systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-04-30 10:57:55 UTC; 19h ago
Docs: http://nginx.org/en/docs/
Process: 15765 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 3416 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 3437 (nginx)
CGroup: /system.slice/nginx.service
├─ 3437 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
├─15766 nginx: worker process
└─15767 nginx: cache manager process

May 01 06:14:21 pf1.myweb.com systemd[1]: Reloading nginx - high performance web server.
May 01 06:14:21 pf1.myweb.com systemd[1]: Reloaded nginx - high performance web server.

[root@pf1 ~]# nginx -t
nginx: [warn] conflicting server name “www.myweb.com” on 167...***:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

sorry, i missed to see the following line on the error log:

nginx: [warn] conflicting server name “www.myweb.com” on 167…***:80, ignored

No idea how to solve this.

Thank you for your help.

ok, site is up.

After rebooting some of the services were down - including apache, so after starting all of it, it is working.

Will investigate more, but for now its ok.

Thanks all

Have another answer? Share your knowledge.