# NGINX - 502 Bad Gateway

**URL:** <https://community.f5.com/t/nginx-502-bad-gateway/70962>\
**Category:** Technical Forums\
**Tags:** security, devops, application-delivery\
**Created:** [November 15, 2022, 6:09am UTC](https://community.f5.com/t/nginx-502-bad-gateway/70962 "2022-11-15T06:09:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashuda](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@Ashuda](https://community.f5.com/u/Ashuda)\
**Post date:** [November 15, 2022, 6:09am UTC](https://community.f5.com/t/nginx-502-bad-gateway/70962/1 "2022-11-15T06:09:54Z")

</div>

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.

 ![502-BadGateway.PNG](https://d20hrnpixdzcsd.cloudfront.net/original/2X/e/ec3b810c4e174f4d7ebbb88130b2aa55eddb019b.png)

```tcl
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;
        server_name www.xxxyyy.com;
        ssl_certificate C:/nginx/keys/zzzzz.pem;
        ssl_certificate_key C:/nginx/keys/yyyyy.key;
	
        location / {
         proxy_pass http://127.0.0.1:4446/;
        }

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

}

```

---

<div class="post-metadata">

**Author:** ![Daniel\_Wolf](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/daniel_wolf/32/1119_2.png) [@Daniel\_Wolf](https://community.f5.com/u/Daniel_Wolf)\
**Post date:** [November 15, 2022, 6:54pm UTC](https://community.f5.com/t/nginx-502-bad-gateway/70962/2 "2022-11-15T18:54:02Z")

</div>

Hi&nbsp; @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.

KR  
Daniel

---

<div class="post-metadata">

**Author:** ![Ashuda](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@Ashuda](https://community.f5.com/u/Ashuda)\
**Post date:** [November 18, 2022, 6:07am UTC](https://community.f5.com/t/nginx-502-bad-gateway/70962/3 "2022-11-18T06:07:22Z")

</div>

Hi&nbsp; @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 ?

---

<div class="post-metadata">

**Author:** ![Daniel\_Wolf](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/daniel_wolf/32/1119_2.png) [@Daniel\_Wolf](https://community.f5.com/u/Daniel_Wolf)\
**Post date:** [November 18, 2022, 11:02am UTC](https://community.f5.com/t/nginx-502-bad-gateway/70962/4 "2022-11-18T11:02:19Z")

</div>

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 ([http://127.0.0.1:4446](http://127.0.0.1:4446)) from the browser.

Check Windows firewall rules.
