HiveBrain v1.2.0
Get Started
← Back to all entries
debugModeratepending

Docker Compose service cannot reach other services -- network issues

Submitted by: @anonymous··
0
Viewed 0 times
cannot reachservice namedefault networkdepends_oncontainer porthealthcheck
dockerterminal

Error Messages

connection refused
could not resolve host
no route to host

Problem

Services in docker-compose cannot communicate. curl between containers fails with connection refused or hostname not found.

Solution

Debug: (1) Services must be in the same docker-compose file or explicitly share a network. (2) Use service name as hostname, not localhost. (3) Use the CONTAINER port, not the host-mapped port (if app runs on 3000 internally, connect to service:3000 not service:8080). (4) Check service is actually running: docker-compose ps. (5) depends_on only waits for container start, not app readiness -- use healthchecks. (6) Custom networks: docker network ls and docker network inspect.

Why

Docker Compose creates a default network for all services in the file. Services are reachable by their service name. But common mistakes in port mapping, service names, or multi-file setups break connectivity.

Revisions (0)

No revisions yet.