Forum Discussion

Ashuda's avatar
Icon for Altostratus rankAltostratus
Nov 15, 2022

NGINX - 502 Bad Gateway

Hi everyone

I have an application running successfully for almost couple of years. But suddenly I am getting the below error. The configuration files are untouched. After then only I tried updating the timeout parameters in config file from the ideas provided through blogs. but no luck. We have used NGINX mainly for reverse proxy, so i hope this is something that needs to be fixed from NGINX (May be IP Blocked. I'm not sure). I have also given below my config file for reference. Kindly guide me in resolving this issue.




worker_processes  1;

events {
    worker_connections  1024;

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  320;

    server {
        listen       443 ssl;
        ssl_certificate C:/nginx/keys/zzzzz.pem;
        ssl_certificate_key C:/nginx/keys/yyyyy.key;
        location / {

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;





3 Replies

  • Hi Ashuda,

    502 Bad Gateway is a generic error. Probably you can learn more looking at the NGINX error log.
    A couple of reasons could be:

    • Backend service failed
    • High load on the server
    •  Service port of backend service blocked
    • Bug in the backend service

    Usually NGINX shows 502 when it has a problem connecting to the backend service. Try to start your troubleshooting in this direction.


    • Ashuda's avatar
      Icon for Altostratus rankAltostratus

      Hi Daniel_Wolf 

      Thank you very much for the reply. In my first level of troubleshooting, I don't see any bugs or service getting failed from the back-end. Regarding the below mentioned points

      • High load on the server
      • Service port of backend service blocked

      I can check whether the service port is blocked from my end. But I have few questions.

      • How can we confirm if there is high load on server in NGINX ?
      • Is there any chance that my server IP/Port getting blocked by NGINX since it acts a reverse proxy ?
      • Apart from NGINX config file. Do I need to check anything on NGINX side ? 
      • Since your config file says C:\nginx\, I guess you are running NGINX on a Windows box.
        Just take a look at Task Manager to see what processes are there and how much CPU / memory is consumed.

        Check that you can access the backend ( from the browser.

        Check Windows firewall rules.