9

When reloading config (specifically for proxy_pass) - occasionally this will be seen: nginx: [emerg] host not found in upstream

However - the upstream server's name WILL resolve in the os (linux) - only nginx seems to have this problem.

This seems to be a recent regression - as it didn't seem to happen previous to 1.0.10 versions.

Has anyone noticed this recently?

Trying to narrow down places to search.

Michael Neale
  • 3,704
  • 5
  • 28
  • 26

1 Answers1

6

Nginx internally caches DNS for 5 minutes (not sure if this is configurable in later versions). Perhaps your resolver is failing for some reason, then Nginx caches this result.

I have seen this on systems with IPv6 enabled since be default the resolver requests both IPv4 and IPv6 records in parallel. This can be seen as a flood by the resolver resulting in a temporary DNS issue. I saw this popup on a box with a lot of email traffic when doing domain name verification.

Try adding:

  options single-request

to /etc/resolv.conf

This causes IPv6/v4 lookups to be done sequentially.

jeffatrackaid
  • 4,142
  • 19
  • 22
  • Thanks for your answer. It turned out this was an error with messing up the hostnames in the config files. Oops. But your answer is actually really useful anyway - so I will mark it as the right one - as it would cause DNS issues, for sure (blasting it with requests). – Michael Neale Jan 31 '12 at 03:35
  • 2
    I have the same issue - what exactly did you do in the config files to fix this (thanks in advance) – Zabs Oct 27 '14 at 10:58
  • You can now add the `value=30s` option to the `resolver` to define how long a resolved IP address should be kept in the `resolver`'s caches. – Alexis Wilke Mar 15 '19 at 17:52