nginx: [emerg] host not found in upstream

Praveen Kumar K S praveenssit at
Mon Dec 14 13:27:50 UTC 2020


1. nginx fails to start when an upstream server is down or not being
2. I can't use the ipaddress because I'm running all services in docker
swarm. So I can only resolve using the service names.
3. Now I get your point. When nginx starts, it should resolve all upstream
servers. Else, it will fail to start.

Now, let me explain my issue. Please let me know if this is possible.
1. Today I have 3 servers defined in upstream. Lets say app1,app2,app3
2. Tomorrow I might scale the app by 2 more. Lets say app4,app5
3. Now I want to define that [app4,app5] in my nginx configuration
4. But I thought of defining app1,2,3,4,5 upfront in nginx conf and scale
my app whenever required. In this case, when nginx is unable to resolve
app4,5, it should ignore and when I scale my app, it should load balance
the requests to all 5.

On Mon, Dec 14, 2020 at 4:23 PM Francis Daly <francis at> wrote:

> On Mon, Dec 14, 2020 at 12:45:00PM +0530, Praveen Kumar K S wrote:
> Hi there,
> > I'm facing issue where if one of the upstream servers is down, nginx
> going
> > to emerg mode with the subjected error.
> Generally, nginx does not care if individual IP:ports defined in an
> "upstream" are accessible or not.
> nginx does care that any hostnames used in "upstream" can be resolved
> at nginx-start-time using the system resolver, and will fail with an
> error like "host not found in upstream" if one does not resolve.
> Are you reporting that nginx stops working when an upstream server is
> down; or are you reporting that nginx fails to start when an upstream
> server is down?
> And if the latter -- does the hostname that you have configured nginx
> to talk to, resolve, when the upstream server is down?
> > My requirement is, nginx should go down when all of the upstream servers
> > are down.
> > But when even one of the upstream servers is up, nginx should still serve
> > the requests by proxying requests to that one live upstream server.
> What you describe in that last sentence is the expected behaviour.
> If you are not seeing that -- can you provide a fuller description of
> your setup?
> If you have unreliable name resolution, you may be able to change your
> "upstream" config to use the IP addresses, which would avoid nginx having
> to try name resolution.
> Cheers,
>         f
> --
> Francis Daly        francis at
> _______________________________________________
> nginx mailing list
> nginx at



*K S Praveen Kumar*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list