How to Fix “502 Bad Gateway”Nginx Error | FIXED| Step By Step

How to Fix “502 Bad Gateway”Nginx Error| FIXED| Step By Step

Many times we can browse the web and find a 502 bad gateway error at Nginx.   There are a few reasons why you will find this message in  your webserver log, and here we will teach you how to fix it.

What is a 502 Bad Gateway Error? [EXPLAINED]

Every time you visit a website your browser sends a request to a web server. The web server receives and processes the request, and then sends back the requested resources.

502 bad gateway error indicate that the request was accepted, but the server prevented the fulfillment of the request. In this case, a 502 bad gateway error specifically means that one server, while acting as a gateway or proxy, has received an invalid response from an inbound server.

Before getting deep into all of this options, you must understand what does the 502 Bad Gateway error message mean. So, the error is and HTTP Status Code error and it’s happening at the gateway. What the hell is a gateway? In simple words, a gateway, is like an access point, a bridge that communicate one service with another, in this case the gateway can be a service/application that is working and receiving requests from Nginx web server.

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 Bad Gateway error.

How to Fix the 502 Bad Gateway Error? [STEP by STEP]

A 502 bad gateway error is typically a problem with the network/server so we will try to solve this from server end/Root level.

Follow these given steps to fix 502 Bad Gateway Error:

  • Step::1 Login to your WHM(Root)
  • Step::2 Go to Service Status
  • Step::3 Now check for httpd service status
  • Step::4 Restart Apache(httpd) from Easy Apache4
  • Step::4 Go to EasyApache4 and uninstall and install any module

Uninstallation and installation process will bring back the Apache in functional mode.

You can also restart Apache by using SSH and typing the command like the one given below:

service httpd restart

Hope this article helped you.. for more queries and suggestions feel free to write or you can also comment below…

For more information on issues related to your website contact Redserverhost


Thanks for Reading!!!

Scroll to Top