gb
  English
Phone:  +1 (217) 636-4164
Skype:  onegbits
  1. Home
  2. Blog
  3. How To Fix 502 Bad Gateway Error on Nginx

How To Fix 502 Bad Gateway Error on Nginx

How To Fix 502 Bad Gateway Error on Nginx

26

Sep, 16

99

How To Fix 502 Bad Gateway Error on Nginx? A 502 error, which is most commonly referred to as “Bad Gateway Error” is generally caused due to timeout of PHP request. A gateway is an access point or bridge that establishes a connection between two services. In order to prevent this error, you need to adjust some server settings i.e. you can increase “Execution Limit” from server settings, by following this article.

How To Fix 502 Bad Gateway Error on Nginx

Method 1. Changes in Nginx Config
#nano /etc/nginx/nginx.conf
http {
    ...
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    ...
}
Method 2. change PHP-FPM to listen on a unix socket or TCP socket.
#nano /etc/php-fpm.d/www.conf
listen = /var/run/php5-fpm.sock
To:
listen = 127.0.0.1:9000
If you are configuring php-fpm to listen on a Unix socket, you should also check that the socket file has the correct owner and permissions.
chmod 0660 /var/run/php5-fpm.sock
chown www-data:www-data /var/run/php5-fpm.sock
How To Fix 502 Bad Gateway Error on Nginx Save
Leave A Comment
We are with you

24 X 7 X 365

+1 (217) 636-4164

©2017 1Gbits. All rights reserved