The docker-compose up command failed because the Docker daemon could not locate the network that your services were configured to use.

This error typically means that Docker Compose tried to connect your containers to a network that doesn’t exist or is no longer accessible. The most common culprit is a mismatch between the network name defined in your docker-compose.yml file and what Docker actually has available.

Here’s a breakdown of the common causes and how to fix them:

1. Network Name Typo or Case Sensitivity:

  • Diagnosis: Carefully examine your docker-compose.yml file. Look for the networks: section and the network names specified under each service’s networks: key. Docker network names are case-sensitive. A simple typo like my_net instead of my_net or MyNetwork instead of mynetwork will cause this.

  • Fix: Correct any typos or case discrepancies in your docker-compose.yml file. For instance, if your docker-compose.yml has:

    services:
      web:
        image: nginx
        networks:
          - my_network # <-- potential typo or case issue here
    networks:
      my_network: # <-- and here
    

    And you intended my_network, ensure both instances match exactly.

  • Why it works: Docker Compose creates networks with specific names. If the name it’s asked to connect to doesn’t exist exactly as specified, it can’t fulfill the request.

2. Network Was Manually Removed:

  • Diagnosis: Check if the network was created independently of docker-compose up and then manually deleted. Run docker network ls and look for a network name that matches what’s in your docker-compose.yml (or a prefixed version like yourprojectname_my_network). If it’s not listed, it’s gone.
  • Fix: Run docker network create your_network_name (replace your_network_name with the name from your docker-compose.yml) before running docker-compose up. Alternatively, remove the external: true flag from the network definition in your docker-compose.yml if you want Compose to manage its creation and deletion.
  • Why it works: If you declared a network as external: true in your docker-compose.yml, Compose expects it to exist already. If it doesn’t, the error occurs. Creating it manually or letting Compose manage it resolves this dependency.

3. Network Created by a Different Compose Project:

  • Diagnosis: If you’re using the same network name across multiple docker-compose.yml files, and one project is already running and using that network, a new docker-compose up might fail if it tries to recreate or access the network in an incompatible way. Run docker network inspect your_network_name to see which containers are attached.
  • Fix: Either use unique network names for each docker-compose.yml file or ensure that only one project is actively managing the network. If you want Compose to manage it, you might need to stop and remove the other project (docker-compose down in the other project’s directory).
  • Why it works: Docker networks are generally project-scoped by default when managed by Compose. If a network is declared as external, and another Compose project has already claimed it, conflicts can arise.

4. Docker Daemon Restarted or System Rebooted:

  • Diagnosis: If Docker was restarted or the host machine rebooted after you created networks manually or with a previous docker-compose up command, those networks might not have been automatically re-attached or might have been lost if not persisted. Check docker network ls.
  • Fix: Run docker-compose up -d again. If the network was declared as external: true and is still missing, you’ll need to recreate it manually using docker network create your_network_name. If it’s not external, docker-compose up should recreate it.
  • Why it works: Networks created by docker-compose up are typically tied to the Compose project’s lifecycle. If the daemon restarts, Compose needs to re-establish these connections. Manually created external networks might need manual re-creation if they weren’t properly persisted.

5. Corrupted Docker Network State:

  • Diagnosis: In rare cases, the Docker daemon’s internal state regarding networks can become corrupted. This is harder to diagnose directly but often shows up as persistent "network not found" errors even after trying other fixes.
  • Fix: The most drastic but effective fix is to prune all unused Docker networks and then try docker-compose up again. Run docker network prune -f. If that doesn’t work, you may need to restart the Docker daemon (sudo systemctl restart docker on Linux) or, as a last resort, reset Docker entirely (which involves stopping all containers and networks).
  • Why it works: This cleans up any lingering, inconsistent network configurations within the Docker daemon, forcing it to rebuild its network state from scratch.

6. Incorrect Network Driver Specified (Less Common for "Not Found"):

  • Diagnosis: While less likely to cause a direct "network not found" error, if you’ve specified a custom network driver in your docker-compose.yml and that driver isn’t installed or available on the Docker host, Compose might fail to create or attach to the network.
  • Fix: Ensure the specified network driver (e.g., overlay, macvlan, or a third-party plugin) is correctly installed and configured on your Docker daemon. For standard bridge networks, this is usually not an issue.
  • Why it works: Docker relies on specific drivers to create and manage network types. If the requested driver is absent, the network cannot be provisioned.

After applying these fixes, run docker-compose up again. If everything is correct, you should see your services starting up.

The next error you’ll likely encounter if you haven’t addressed all configuration issues is a "Service […] is unhealthy" message, indicating that while the container started, the application inside isn’t passing its health checks.

Want structured learning?

Take the full Docker course →