Node.js DNS Resolution Failure in Containerized Environments #7829
Unanswered
sukkola
asked this question in
Error / Bug Report
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report: Node.js DNS Resolution Failure in Containerized Environments
Summary
Wiki.js containers fail to make HTTPS connections to external services (OAuth2 providers, storage backends, etc.) in certain Kubernetes/containerized environments, despite DNS resolution working at the shell level.
Affected Features:
Symptoms
From within the Wiki.js container, the following behavior is observed:
Root Cause Analysis
The Problem
Node.js provides two different DNS resolution mechanisms:
dns.resolve4()/dns.resolve()dns.lookup()/ HTTPS modulegetaddrinfo()function/etc/resolv.confThe HTTPS module uses
dns.lookup()internally, which fails while direct DNS queries work.Why It Happens
The system's
getaddrinfo()can fail in containerized environments due to:Incorrect
/etc/resolv.confconfigurationDNS query behavior differences
dns.resolve4()- Direct DNS queries, bypasses system resolverdns.lookup()- Uses system resolver with search domain logicTimeout and retry issues
Testing Instructions
To reproduce and verify the issue:
Test 1: Check if dns.lookup() fails
Expected output showing the bug:
Test 2: Check HTTPS connection
Expected output showing the bug:
Test 3: Verify curl works
Expected output showing curl works:
Test 4: Inspect system DNS configuration
Example output:
If you see issues like:
ndots:5or higher (causes excessive search domain lookups)timeout:5or higher (slow DNS queries)Then you've identified the DNS configuration problem.
Proposed Solution
For Helm Chart Maintainers
Add optional DNS configuration support to the Helm chart that allows users to customize DNS behavior without imposing it on all deployments:
File:
dev/helm/values.yamlAdd a new optional section:
File:
dev/helm/templates/deployment.yamlAdd DNS configuration to the pod spec if provided:
For Users Experiencing the Issue
In your Helm values or Kustomize patch, enable DNS configuration:
For Kubernetes Users: Generic Workaround
If your Kubernetes cluster has this issue, apply a generic DNS configuration patch to Wiki.js deployments:
Root Cause Details
The issue stems from how Node.js's
dns.lookup()interacts with the system resolver:https.get()is called, it usesdns.lookup()to resolve the hostnamedns.lookup()calls the system'sgetaddrinfo()functiongetaddrinfo()uses/etc/resolv.confto determine DNS behavior/etc/resolv.confis misconfigured or has suboptimal settings,getaddrinfo()fails or hangsdns.resolve4()bypasses the system resolver and works finecurl(which uses different DNS libraries) also works fineWhy This is Hard to Debug
Impact
This bug affects:
Reproduction Environment
Beta Was this translation helpful? Give feedback.
All reactions