Report this

What is the reason for this report?

502 Bad Gateway after droplet reboot

Posted on November 19, 2020

I powered off the droplet to take a snapshot. After powering it back on, I’m getting a 502 Bad Gateway error.

I saw multiple questions on the same topic but none of the solutions worked for me.

I tried restarting nginx & php-fpm but no effect. Both seem to be running OK… UFW also allows connections on ports 80 & 443.

CPU/RAM/DISK usage on the droplets seems way below limit.

I also tried to restore the droplet from a 2-week old backup (when it was for sure working), but that didn’t work either.

I’ve ran some of the common commands below, with outputs included

/var/log/nginx/error.log output:

2020/11/19 11:41:54 [error] 29003#29003: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 99.10.79.177, server: example.com, request: "GET /wordpress HTTP/2.0", upstream: "http://127.0.0.1:8000/wordpress", host: "example.com"
2020/11/19 11:41:54 [error] 29003#29003: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 99.10.79.177, server: example.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://127.0.0.1:8000/favicon.ico", host: "example.com", referrer: "https://example.com/wordpress"
nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

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) Drop-In: /etc/systemd/system/nginx.service.d └─override.conf Active: active (running) since Wed 2020-11-18 19:24:38 PST; 16h ago Docs: man:nginx(8) Process: 1113 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS) Process: 1037 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 838 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 1102 (nginx) Tasks: 9 (limit: 2361) CGroup: /system.slice/nginx.service ├─1102 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; ├─1104 nginx: worker process └─1105 nginx: cache manager process

Nov 18 19:24:36 example systemd[1]: Starting A high performance web server and a reverse proxy server… Nov 18 19:24:38 example systemd[1]: Started A high performance web server and a reverse proxy server.

systemctl status php7.2-fpm

● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2020-11-18 19:55:51 PST; 15h ago Docs: man:php-fpm7.2(8) Main PID: 9167 (php-fpm7.2) Status: “Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec” Tasks: 3 (limit: 2361) CGroup: /system.slice/php7.2-fpm.service ├─9167 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf) ├─9187 php-fpm: pool www └─9188 php-fpm: pool www

Nov 18 19:55:51 example systemd[1]: Stopped The PHP 7.2 FastCGI Process Manager. Nov 18 19:55:51 example systemd[1]: Starting The PHP 7.2 FastCGI Process Manager… Nov 18 19:55:51 example systemd[1]: Started The PHP 7.2 FastCGI Process Manager.

netstat -plant
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      29000/nginx: master 
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      663/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      931/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1231/master         
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      29000/nginx: master 
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      962/mysqld          
tcp        0    340 138.197.197.242:22      99.10.79.177:58923      ESTABLISHED 27637/sshd: root@pt 
tcp        0      0 138.197.197.242:443     99.10.79.177:61303      ESTABLISHED 29003/nginx: worker 
tcp6       0      0 :::80                   :::*                    LISTEN      29000/nginx: master 
tcp6       0      0 :::22                   :::*                    LISTEN      931/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1231/master         
tcp6       0      0 :::8090                 :::*                    LISTEN      503/apache2      

The developer cloud

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

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.