nginx network_error ai_generated true

upstream DNS resolution timed out

ID: nginx/upstream-dns-resolution-timed-out

Also available as: JSON · Markdown · 中文
88%Fix Rate
86%Confidence
1Evidence
2023-11-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx 1.18.0 active — — —
nginx 1.20.2 active — — —
nginx 1.22.1 active — — —
nginx 1.24.0 active — — —
nginx 1.25.3 active — — —

Root Cause

Nginx cannot resolve the upstream hostname because the resolver is not configured, the DNS server is unreachable, or the hostname is invalid.

generic

中文

Nginx无法解析上游主机名,原因是未配置解析器、DNS服务器不可达或主机名无效。

Official Documentation

http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver

Workarounds

  1. 90% success Configure a valid resolver in the http block: resolver 10.0.0.53 valid=10s; (replace with your DNS server IP)
    Configure a valid resolver in the http block: resolver 10.0.0.53 valid=10s; (replace with your DNS server IP)
  2. 85% success If using Docker, set dns: in docker-compose.yml or add --dns flag to docker run
    If using Docker, set dns: in docker-compose.yml or add --dns flag to docker run
  3. 80% success Check /etc/resolv.conf and ensure nginx has network access to the DNS server
    Check /etc/resolv.conf and ensure nginx has network access to the DNS server

中文步骤

  1. 在http块中配置有效的解析器:resolver 10.0.0.53 valid=10s;(替换为你的DNS服务器IP)
  2. 如果使用Docker,在docker-compose.yml中设置dns:或在docker run中添加--dns标志
  3. 检查 /etc/resolv.conf 并确保nginx具有到DNS服务器的网络访问权限

Dead Ends

Common approaches that don't work:

  1. 60% fail

    If the server has no outbound internet access, public DNS won't work; need internal DNS.

  2. 40% fail

    This bypasses DNS but makes the config brittle if IPs change; not a proper fix.

  3. 80% fail

    If DNS is unreachable, timeout increase just delays the error.