A container cannot join a Docker network that still holds an endpoint with its name
Your error
Error response from daemon: endpoint with name web already exists in network mynet2 more lines it can showFix it fast
Most common cause, 1 of 2A stale endpoint survived after its container was gone
Force-disconnect the name from the network.
docker network disconnect -f mynet web
docker compose up -dShort answer
"endpoint with name web already exists in network mynet" means the network already holds an endpoint named after the container. Either a stale endpoint outlived an unclean daemon stop, or a script connects a container that is already attached. Delete the stale one with docker network disconnect -f, or skip the repeated connect (Docker Engine 28 and 29).
Which cause do you have?
Find out whether a container with the name from the error still exists, and if it does, which networks it already belongs to. No container at all points to a leftover endpoint; a running container that already lists the network points to a second connect.
docker ps -a --filter name=web --format '{{.Names}} {{.Status}}'
docker inspect --format '{{json .NetworkSettings.Networks}}' webThen find the line you see in this list and open its fix:
- 1A stale endpoint survived after its container was gone
docker ps -a lists no container with that name, often right after a daemon crash, a killed dockerd or a host that lost power - 2The running container is being connected to a network it already joined
docker inspect shows the network already present for a running container, and the error comes from a docker network connect line in a deploy script or hook
What does the error look like?
Error response from daemon: endpoint with name web already exists in network mynetError response from daemon: endpoint with name db already exists in network myproject_defaultError response from daemon: service endpoint with name web already exists
Cause 1 of 2
A stale endpoint survived after its container was gone
You seedocker ps -a lists no container with that name, often right after a daemon crash, a killed dockerd or a host that lost power
Check
The error appears because the network refuses a second endpoint with a name it already has, and endpoints take the container's name. When dockerd stops without a clean shutdown, it can leave network state behind for a container that no longer exists, and every new container with the same name then trips the check. Older engines printed the same refusal as 'service endpoint with name ... already exists'.
docker ps -a --filter name=web
docker network lsFix
Force-disconnect the name from the network. When -f is given and no container of that name exists, the daemon looks the endpoint up by name in that network and deletes it.
docker network disconnect -f mynet web
docker compose up -dVerify
The container starts and shows the network in its settings.
docker inspect --format '{{json .NetworkSettings.Networks}}' webConfirmed by github.com
Cause 2 of 2
The running container is being connected to a network it already joined
You seedocker inspect shows the network already present for a running container, and the error comes from a docker network connect line in a deploy script or hook
Check
For a running container, docker network connect always asks the network for a new endpoint named after the container. If the container joined that network earlier, through docker run --network, a Compose networks entry or an earlier run of the same script, the name is taken and the daemon answers with this error.
docker inspect --format '{{json .NetworkSettings.Networks}}' web
grep -rn "docker network connect" scripts/ .github/ 2>/dev/nullFix
Make the connect step idempotent: attach only when the network is missing from the container's settings, or declare the network in Compose and drop the manual connect.
if ! docker inspect --format '{{json .NetworkSettings.Networks}}' web | grep -q '"mynet"'; then
docker network connect mynet web
fiVerify
Running the script twice in a row finishes without the error, and mynet appears once in the container's networks.
docker inspect --format '{{range $name, $net := .NetworkSettings.Networks}}{{$name}} {{end}}' webConfirmed by github.com
How do I stop it coming back?
- Stop containers and the Docker service cleanly before host maintenance or a reboot, so endpoints are released instead of left behind.
- Guard every docker network connect in scripts with a check of the container's current networks.
- Declare networks in compose.yaml instead of connecting containers by hand after they start.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, Dispatch Pro.