GrepBoard/Manuals
605 manuals ·

Fix nginx no servers are inside upstream

·Tested on nginx 1.28.0 (Docker) · 2026-11·Test scope ↓·4 steps

Fix nginx no servers are inside upstream by finding the empty group, adding an actual backend server, and checking the configuration with nginx -t.

output
2026/11/21 23:19:42 [emerg] 1#1: no servers are inside upstream in /lab/before.conf:4nginx: [emerg] no servers are inside upstream in /lab/before.conf:4nginx: configuration file /lab/before.conf test failed

The nginx error no servers are inside upstream means nginx read an upstream group with zero server entries. Add an actual backend to that group and rerun nginx -t.

[1] Open the file named in the error and look above the reported line for the upstream declaration. The container ran nginx -t -c /lab/before.conf. Line 4 in the output is the closing brace of upstream lab. The nginx 1.28.0 source checks for zero registered server entries after reading the whole block. If the block came from an include, open the included file named in the output. For a generated configuration, find the missing server list in the generated file and fix the input that supplies it.

/lab/before.conf
events {}http {    upstream lab {    }    server {        listen 127.0.0.1:18080;        location / {            proxy_pass http://lab;        }    }}

This file already has a server { … } block with a listen directive. That block defines where nginx accepts incoming requests. To register a backend for lab, put server address:port; inside upstream lab { … }. The proxy_pass http://lab; line refers to that group.

[2] Save a known-good copy of your production configuration outside the paths matched by its include directives. Specify the address and port where the application actually listens. The test adds one line, server 127.0.0.1:18081;. A loopback address works when the backend listens on that port in the same network namespace as nginx. For a backend in a separate container, use the service address and port reachable from the nginx container.

/lab/after.conf
events {}http {    upstream lab {        server 127.0.0.1:18081;    }    server {        listen 127.0.0.1:18080;        location / {            proxy_pass http://lab;        }    }}

[3] Test the edited configuration. Use nginx -t for an instance using the default configuration file. If the service runs with a different file, pass that file with -c. The container test loads the edited file from /lab/after.conf.

console
$ nginx -t -c /lab/after.conf
output
nginx: the configuration file /lab/after.conf syntax is oknginx: configuration file /lab/after.conf test is successful

The exit code was 1 before the change and 0 after it. The edited configuration passed with the backend stopped. To check backend connectivity, send a request through the route.

[4] Reload the configuration using your deployment's normal procedure after the test passes. For a directly managed nginx instance, use nginx -s reload. Send a request to the route and check the response and error log. If the response changes unexpectedly, restore the saved configuration, test and reload it, then check the same route again.

If the configuration passes but a request returns 502 with connect() failed, check nginx 502 Bad Gateway logs. If a variable in proxy_pass produces no resolver defined to resolve when a request arrives, see the nginx resolver error guide.

Analyze your Nginx log in the browser ↗ — nothing is uploaded.

#nginx#upstream#proxy_pass#nginx -t