- Nginx running as proxy for Apache web server.
- Nginx running with PHP-FPM daemon.
- Nginx running with other services as gateway.
- Bad buffering/timeout configuration.
- Nginx as Proxy for Apache: in this case, the gateway is Apache. When you use Nginx as proxy for Apache, if apache dies or it’s not well configured, it can cause this 502 error. How to fix it? Most of the times, restarting apache web server will get rid of this, but you must check the log files to know why exactly this was caused.
- Nginx with PHP-FPM: same as Apache example, let’s imagine your php daemon stop working, or get’s overloaded by requests, it will not work properly and the all the php requests from nginx would not be served, so, an error will appear. How to fix it? Restart php-fpm daemon and check the logs.
- Nginx with other services/apps: try restarting the other service behind nginx and explore the logs to find the reason why it happened.
http {
...
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
...
}
2) Ensure your php-fpm service is listening according to what you’ve configured in nginx, it can be either this two options:
Edit www.conf file (in CentOS it is located at /etc/php-fpm.d/www.conf and try with one of this two options:
listen = /var/run/php5-fpm.sock
or
listen = 127.0.0.1:9000
After that, just restart the php-fpm service.
3) Disable APC Cache if used, instead try Xcache, apc can cause this kind of issues under particular enviroments causing segmentation faults.
4) I recently found another cause of 502 bad gateway error, check it out here: php5-fpm.sock failed (13: Permission denied) errorRevisions
- January 13, 2016 @ 15:17:24 [Current Revision] by admin
- January 13, 2016 @ 15:17:24 by admin
Revision Differences
There are no differences between the January 13, 2016 @ 15:17:24 revision and the current revision. (Maybe only post meta information was changed.)
No comments yet.