Docker Compose Network Not Found: Fix in 5 Minutes
Getting 'network not found' or 'network ... declared as external, but could not be found' from Docker Compose? Here is exactly how to diagnose and fix external network references, stale networks, and project name mismatches.
This error shows up in two flavors — a genuinely missing network, or Compose looking for the wrong network name because of a project-name mismatch. Here is how to tell which one you have.
Step 1: Read the Exact Error
docker compose up
# ERROR: Network app_default declared as external, but could not be found.
# Please create the network manually using `docker network create app_default`
# and try again.The network name Compose is looking for (app_default) tells you exactly what to check — it's either genuinely missing, or it exists under a slightly different name.
Cause 1: Network Genuinely Doesn't Exist Yet
docker network ls | grep app_default
# (no output — confirmed missing)Fix — create it:
docker network create app_default
docker compose upIf the network is referenced as external: true in your compose file, Compose expects it to already exist — it will never create it for you.
networks:
app_default:
external: true # Compose assumes this exists alreadyCause 2: Project Name Mismatch (Most Common Cause)
Docker Compose prefixes network names with the project name — by default, the directory name your docker-compose.yml lives in. If you run Compose from a different directory, or with a different -p flag, the network name changes.
# Yesterday, you ran this from /home/user/myapp/
docker compose up
# Created network: myapp_default
# Today, you ran it from /home/user/myapp-deploy/ (a symlink or renamed clone)
docker compose up
# Looking for: myapp-deploy_default ← different name, "not found"# Check what project name Compose thinks it's using
docker compose config --format json | grep -i "name"
# List actual networks to compare
docker network lsFix — pin the project name explicitly so it's consistent regardless of directory:
# docker-compose.yml
name: myapp # Explicit project name — Compose v2.20+# Or override at runtime
docker compose -p myapp upThis is the single most common cause in CI environments, where the checkout directory name can differ between local dev and the CI runner.
Cause 3: Network Was Removed by docker compose down But Referenced Elsewhere
# If another compose file or a manually-run container references
# a network that a previous `docker compose down` already deleted:
docker compose down # Removes networks not marked external
docker compose -f other-service/docker-compose.yml up
# ERROR: network myapp_default not founddocker compose down removes networks it created (non-external ones) by default — if a second, separate Compose project depends on the first project's network, that dependency breaks the moment the first project goes down.
Fix — make shared networks external and long-lived, not owned by any single Compose project:
docker network create shared_backend# Both compose files reference the same external network
networks:
shared_backend:
external: trueCause 4: Compose File Syntax — Wrong Network Reference
# BAD — service references a network name that doesn't match
# the top-level networks: key
services:
api:
networks:
- backend # references "backend"
networks:
app_backend: # but it's actually defined as "app_backend"
driver: bridgedocker compose config # Validates and shows the resolved config — catches this immediatelyFix — match the names exactly:
services:
api:
networks:
- app_backend
networks:
app_backend:
driver: bridgeVerify the Fix
docker compose config # Confirms resolved network names, catches typos
docker network ls # Confirms what actually exists
docker compose up --remove-orphans # Clean start, removes stale containers from renamed networks--remove-orphans is worth running after any project-name or network-naming fix — it clears out containers left behind under the old naming scheme that would otherwise silently keep running disconnected from your current stack.
More Docker troubleshooting? Read our Docker container keeps restarting fix and Docker build slow no cache fix.
Today I Fixed
Short real fixes from production — posted daily
Stay ahead of the curve
Get the latest DevOps, Kubernetes, AWS, and AI/ML guides delivered straight to your inbox. No spam — just practical engineering content.
Related Articles
AWS ECR Image Push Access Denied — Every Fix (2026)
docker push to ECR fails with 'Access Denied' or 'no basic auth credentials'. Here's every cause — expired token, wrong region, missing IAM permissions, ECR URI mismatch — and the exact fix for each.
AWS ECR Push Denied: no basic auth credentials — Fix
Getting 'no basic auth credentials' or 'denied: Your authorization token has expired' when pushing to AWS ECR? Here are the exact commands to fix authentication for Docker, GitHub Actions, and Kubernetes.
AWS ECS Task Keeps Stopping — How to Fix It (2026)
Your ECS task starts and then immediately stops or keeps restarting. Here's every reason this happens and how to debug and fix it.