Error response from daemon: error while removing network: network ... has active endpoints means a container is still attached to the network. The message names it. Disconnect that container, or remove it, and then docker network rm works.

docker network inspect lists every attached container when the message is not enough, and docker network disconnect detaches one without stopping it.

The error

PS> docker network rm fix8-cli-net
Error response from daemon: error while removing network: network fix8-cli-net has active endpoints (name:"fix8-cli-n1" id:"abea9ab7d76e")
exit status 1

Why it happens

Attaching a container to a user-defined network creates an endpoint: the container's interface and address on that network. The engine will not delete a network while any endpoint exists, since a container is still using it. In the test the container fix8-cli-n1 was started with --network fix8-cli-net and was still running.

The text in brackets is the useful part: it gives the container name and the endpoint ID. The ID in the message, abea9ab7d76e, did not match the container's own ID, which began 0609e541f77c, so search by the name rather than the ID. A second run showed what it is: the message gave id:"f5949f9f394e", and docker network inspect listed the container with endpoint=f5949f9f394ecfbf..., the endpoint ID on that network.

The fix

PS> docker network inspect fix8-cli-net --format "{{range .Containers}}{{.Name}} {{end}}"
fix8-cli-n1
PS> docker network disconnect fix8-cli-net fix8-cli-n1
PS> docker network rm fix8-cli-net
fix8-cli-net

The inspect line prints the names of attached containers; here it was one. After docker network disconnect the network had no endpoints and was removed, and the container itself was removed afterwards with docker rm -f. For a Compose project, docker compose down removes the project's containers before its networks, which avoids the error for containers the project created itself.

Two details of the message are worth knowing when you search logs for it. It ends with a separate line, exit status 1, which belongs to the same error and not to a second failure. And the test had a single attached container; if several share the network, run the inspect line again after each disconnect until it prints no names at all, and only then remove the network.

How it was reproduced

Docker Desktop on Windows 11, client and engine 29.9.2, Windows PowerShell 5.1, the cached alpine:latest image. docker network create fix8-cli-net, then docker run -d --name fix8-cli-n1 --network fix8-cli-net alpine sleep infinity, then docker network rm gave the message above; disconnecting the container let the removal succeed. The network and container names are the test's own.

Frequently asked

How do I find which containers are using a Docker network?
Run docker network inspect <network> and read the Containers section, or add --format with a range over .Containers to print only the names.
How do I remove a Docker network that has active endpoints?
Disconnect each attached container with docker network disconnect <network> <container>, or remove those containers, then run docker network rm again.
Is the id in the active endpoints message the container ID?
No, it is the endpoint ID on that network. Use the name shown next to it to find the container.

More decoded errors in the Fixes category. A network that is missing rather than busy is covered in network not found.