Has anyone encountered this problem? I'm experiencing a brief 502 error

Please use this template for troubleshooting questions.

**My issue:**Has anyone encountered this problem? I’m experiencing a brief nginx 502 error, but my backend is working fine.

**How I encountered the problem:**Last night, my nginx encountered a 502 error, indicating no healthy upstream and preventing requests from being sent to any backend. This issue only lasted about 7 seconds. My nginx is behind a GCP load balancer.

Solutions I’ve tried:I did nothing.

**Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric):**nginx/1.26.2

**Deployment environment:gcloud vm instance,**Ubuntu 24.04.1 LTS

Minimal reproducible NGINX config:

worker_processes auto;

events {
worker_connections 1024;
}

http {

limit zones for request rate

limit_req_zone $server_name zone=global_limit:10m rate=200r/s;
limit_req_zone $request_uri zone=uri_limit:10m rate=50r/s;

upstream pay-api-open {
    server 10.149.0.21:18092;
    server 10.149.0.22:18092;
    keepalive 65;
}

server {
    listen 80;
    server_name example.id prod.aaa.id;

    # Paths where issue occurs
    location ~ ^/(gateway/order/detail/v2|api/digitCoin/coinList|gateway/getPayMethod/v2|gateway/order/status|gateway/preserveApp) {
        limit_req zone=global_limit burst=2000 nodelay;
        limit_req zone=uri_limit burst=500 nodelay;
        limit_req_status 430;

        proxy_pass http://pay-api-open;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location / {
        proxy_pass http://pay-api-open;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
    }
}

}

NGINX access/error log: (Tip → You can usually find the logs in the /var/log/nginx directory.)
access.log:
“2025-10-30 22:49:49” - “8.215.82.129” - “prod.aaa.id” - “python-requests/2.32.3” - “ID” - “” - “0.000” - “pay-api-open” - “0.000” - “POST /gateway/prepaidOrder HTTP/1.1” - “502” - “150” - “” - “” - “172.17.1.13”
error.log: 2025/10/30 22:49:55 [error] 2184104#2184104: *32398187 no live upstreams while connecting to upstream, client: 172.17.1.10, server: example.id, request: “POST /gateway/getPayMethod/v2 HTTP/1.1”, upstream: “https:pay-api-open/gateway/getPayMethod/v2”, host: “test.aaa.id”

Hey @jufu_li!

By all accounts, my initial suggestion would be that the backend stopped being healthy for the 7 seconds the requests failed. Is there any chance that could have been the case?

It’s unlikely that both backends would become unhealthy within 7 seconds. The problem is more likely that a backend API is experiencing continuous timeouts, causing Nginx to conclude that both backends are faulty.

NGINX determines the health of each upstream server separately, so that is unlikely to have been the case :slight_smile:

Thank you for your reply. We are trying to reproduce the result.

1 Like