Guidelines

How do I fix nginx 502 Bad Gateway?

How do I fix nginx 502 Bad Gateway?

How to Fix a 502 Bad Gateway Error

  1. Reload the page.
  2. Look for server connectivity issues.
  3. Check for any DNS changes.
  4. Sift through your logs.
  5. Fix faulty firewall configurations.
  6. Comb through your website’s code to find bugs.
  7. Contact your host.

Why is my 502 Bad Gateway nginx?

A 502 Bad Gateway Error means that the web server you’ve connected to is acting as a proxy for relaying information from another server, but it has gotten a bad response from that other server. It’s possible the server is overloaded or there are network issues between the two servers, and it’s just a temporary problem.

What is the error 502 bad gateway?

The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server.

What causes nginx to return a 502 Bad Gateway?

In production, PHP-FPM is often deployed behind an NGINX web server. NGINX proxies web requests and passes them on to PHP-FPM worker processes that execute the PHP application. NGINX will return a 502 Bad Gateway error if it can’t successfully proxy a request to PHP-FPM, or if PHP-FPM fails to respond.

What is PHP FastCGI Process Manager in Nginx?

PHP-FastCGI Process Manager ( PHP-FPM) is a daemon for handling web server requests for PHP applications. In production, PHP-FPM is often deployed behind an NGINX web server. NGINX proxies web requests and passes them on to PHP-FPM worker processes that execute the PHP application.

What causes a service to fail in Nginx?

The reasons for service failure can range from traffic spikes and resource limits to disk errors and DDoS attacks. If you suspect a backend service is unresponsive or failed, you can try killing all unresponsive processes and restarting the service. For instance, here’s one way we kill defunct PHP-FPM processes and restart services.

Why is my Nginx not responding to PHP-FPM?

If NGINX is unable to communicate with PHP-FPM for any of these reasons, it will respond with a 502 error, noting this in its access log ( /var/log/nginx/access.log) as shown in this example: NGINX’s access log doesn’t explain the cause of a 502 error, but you can consult its error log ( /var/log/nginx/error.log) to learn more.