Skip to content

nginx startup stuck in loop: curl returns 000 resolving 'api_server' on Alpine (wget works) #9794

@Opeple0627

Description

@Opeple0627

Description

After starting Onyx with Docker Compose, nginx remains stuck in its startup health-check loop indefinitely, making localhost:3000 unreachable:

Waiting for API server to boot up; this may take a minute or two...
API server responded with 000, retrying in 5 seconds...
API server responded with 000, retrying in 5 seconds...
(repeats forever)

Root Cause

The nginx startup script (run-nginx.sh) uses curl to health-check the API server:

status_code=$(curl -o /dev/null -s -w "%{http_code}\n" "http://${ONYX_BACKEND_API_HOST}:8080/health")

On Alpine Linux, curl fails to resolve api_server via Docker's internal DNS (127.0.0.11), always returning 000 (connection failure). However, wget resolves the same hostname correctly:

# Inside nginx container:
curl -s http://api_server:8080/health   # → 000 (fails)
wget -qO- http://api_server:8080/health # → {"success":true} (works)

The issue appears to be a DNS resolution incompatibility between Alpine's musl-based curl and Docker's embedded DNS resolver (127.0.0.11) with search localdomain in /etc/resolv.conf.

Steps to Reproduce

docker compose --profile s3-filestore up -d
docker logs onyx-nginx-1 --follow
# Observe "API server responded with 000" repeating indefinitely

Workaround

Manually add the API server IP to /etc/hosts inside the nginx container:

# Get api_server IP
API_IP=$(docker inspect onyx-api_server-1 --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
docker exec onyx-nginx-1 sh -c "echo '$API_IP api_server' >> /etc/hosts"

Suggested Fix

Replace curl with wget in the health-check loop in run-nginx.sh, or use the IP address directly, or switch to a curl invocation that bypasses DNS (e.g. --resolve).

Environment

  • OS: Ubuntu 24.04.4 (VMware)
  • nginx image: nginx:1.25.5-alpine
  • Docker version: latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions