How to Fix 502 Bad Gateway Error

What exactly is a 502 Bad gateway? Well, if we go by the basics, it is an HTTP status code which signifies that one server on the internet has received an invalid response from another server. This error is completely independent of your particular setup that is to say that you could find one in any browser on any operating system or any device. The 502 Gateway Error can be customized according to the person handling the website. Mostly, it is seen in the following ways.

Recommended: 

Now that we have covered the definition let us focus on what this article has to offer. We here have made a list for your better understanding.

  • 502 Bad Gateway
  • 502 bad gateway nginx fix
  • 502 bad gateway phpstorm
  • 502 bad gateway php

Fix 502 Bad Gateway Error

Without any further ado, let us get on with the ways to deal with the issue on our hands.

  1. First of all, what you can do is try loading the URL again. Press F5 or Ctrl-R on your keyboard, or by simply clicking the refresh or reload button. Although the error indicates a networking error outside your control, it could be temporary. So, by trying the page again, it may resolve the issue.
  2. Start a new browser session by closing all the browsers that are open and then opening a new one. After this try opening the web page again. It might be a possibility that the 502 errors that you received were because of an issue on your computer that occurred sometime during the time when you used the browser. Restarting the browser would help resolve the problem in no time. So, don’t worry.
  3. You can also clean your browser’s cache. It is important that you do this regularly but if we talk about this topic. Sometimes outdated or corrupted files which are stored by your browser could be the reason behind the 502 gateway problem that is troubling you. Remove the cached files and then try the page again. I am sure the problem will be gone if this the reason behind it.
  4. The next option that we have is if of trying your browser in Safe Mode. Running a browser in a Safe Mode means to execute it with default settings and sans any add-ons or extensions which also includes the toolbars. If you see that the 502 error no longer appears while running your browser in Safe Browser Mode then it can be construed that some browser extension or setting was the reason, this problem was popping up. To tackle it permanently you can go to your browser settings to default or selectively disable browser extensions to single out the root cause.
  5. By changing the NGINX config. Maybe the buffer and the timeout parameters are configured incorrectly for the server that is being used by you, or maybe they don’t suffice anymore. You can locate the NGINX configuration file at /etc/nginx/nginx.conf. if you try increasing the following items then it may aid you.
  6. For 502 bad gateway phpstorm you can resort to non-thread safe one from PHP instead of thread safe one that comes with WAMP.
  7. You should also try checking that the php-fpm is running with ps aux | grep php to make sure. If you can’t find any php-fpm processes in the output, then you may be required to re-install php-fpm. Next thing that you can do is get php-fpm to listen on the correct host/port.

So, these were some of the ways that you can try to resolve the 502 errors that you are facing right now. I hope this article was helpful.

Thanks for reading.