Starting n8n with docker compose up -d failed with Bind for 0.0.0.0:5678 failed: port is already allocated. Another n8n was already using port 5678. Stopping it wasn’t the whole fix: n8n opened only after Docker created its container again.
What I Was Doing
I was setting up the Scheduled Daily Log for n8n from its zip, following How to Set Up and Run the Scheduled Daily Log for n8n. Its compose.yml runs n8n 2.48.7 in Docker and opens it on port 5678. On the same Mac, with Docker Desktop 4.99, the n8n from How to Install n8n with Docker was still running. In its folder, I started n8n:
docker compose up -d
What I Expected
n8n to start in the background and open at http://localhost:5678.
What I Got
Docker created a volume and a network for n8n, then stopped at the container:
[+] up 3/3
✔ Volume scheduled-daily-log-n8n_n8n_data Created 0.0s
✔ Network scheduled-daily-log-n8n_default Created 0.1s
✘ Container scheduled-daily-log-n8n-n8n-1 Error response from daemon: failed to s... 0.4s
Error response from daemon: failed to set up container networking: driver failed programming external connectivity on endpoint scheduled-daily-log-n8n-n8n-1 (3cd81faaea2b089061a80910c7650cb849ede3647ce073ffe681b4403dd713c3): Bind for 0.0.0.0:5678 failed: port is already allocated
The other n8n held port 5678, so I stopped it and ran docker compose up -d again. This time there was no error:
[+] up 1/1
✔ Container scheduled-daily-log-n8n-n8n-1 Started 0.1s
But http://localhost:5678 still didn’t open n8n:

What I Checked
The command docker compose ps lists the containers of the project in this folder, with their status and their ports (Docker’s reference (opens in a new tab)):
docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
scheduled-daily-log-n8n-n8n-1 docker.io/n8nio/n8n:2.48.7 "tini -- /docker-ent…" n8n About a minute ago Up About a minute 5678/tcp
n8n was up, but the PORTS column showed only 5678/tcp, the port inside the container. A container your computer can reach shows a mapping there, such as 127.0.0.1:5678->5678/tcp: port 5678 on your computer, connected to port 5678 in the container. This container had no mapping.
Docker’s reference for docker compose up (opens in a new tab) explains why running it again didn’t help: Compose recreates an existing container only when the service’s configuration or image changed after the container was created. Its --force-recreate option recreates the containers anyway.
Why It Happens
Only one program can use a port at a time. The first docker compose up -d created n8n’s container, but couldn’t connect it to port 5678, because the other n8n had it. Stopping the other n8n didn’t change compose.yml, so the second docker compose up -d started that same container again, still without its port.
The Fix
Free port 5678 or choose another port, then let Compose create the container again.
Stop the Other n8n
Stop the n8n that uses port 5678. If it’s the n8n from How to Install n8n with Docker, its Stop and Start n8n section has the stop command.
Or Give This n8n Another Port
To keep the other n8n running, give this one a free port instead, such as 5701. The Scheduled Daily Log’s compose.yml takes the port from N8N_PORT in its .env file. In its folder, run:
echo "N8N_PORT=5701" >> .env
The >> adds the line to the end of .env, after your time zone line.
Then Create the Container Again
Either way, run this in the same folder:
docker compose up -d --force-recreate
The --force-recreate option makes Compose stop the container and create a new one, even when nothing in compose.yml changed. Compose keeps the volumes when it recreates a container (Docker’s reference (opens in a new tab)), so n8n’s data stays.
After the Fix
Compose created the container again and started it:
[+] up 1/1
✔ Container scheduled-daily-log-n8n-n8n-1 Started 2.1s
Now docker compose ps showed the mapping:
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
scheduled-daily-log-n8n-n8n-1 docker.io/n8nio/n8n:2.48.7 "tini -- /docker-ent…" n8n 8 seconds ago Up 5 seconds 127.0.0.1:5678->5678/tcp
and http://localhost:5678 opened n8n’s first page, where you create the owner account:

With N8N_PORT=5701, the PORTS column shows 127.0.0.1:5701->5678/tcp instead. n8n then opens at http://localhost:5701, and the other n8n keeps port 5678.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Running docker compose up -d again after freeing the port | Docker says Started, but localhost refuses to connect | Run docker compose up -d --force-recreate |
Opening http://localhost:5678 after setting N8N_PORT=5701 | You reach the other n8n | Open http://localhost:5701 |
Adding the port with > instead of >> | .env loses your time zone line, and n8n runs on New York time | Use >>, which adds a line |
FAQ
How do I find what’s using port 5678?
If it’s a Docker container, this lists it:
docker ps
Look for 5678 in the PORTS column, such as 0.0.0.0:5678->5678/tcp. The NAMES column tells you which container it is.
Will recreating the container delete my workflows?
No. n8n keeps your workflows in a Docker volume, and Compose keeps volumes when it recreates containers (Docker’s reference (opens in a new tab)). docker compose down -v is the command that deletes the volume.
Conclusion
The error port is already allocated means another program already uses the port, here a second n8n on 5678. Stop it, or give this n8n another port with N8N_PORT, then run docker compose up -d --force-recreate. A plain docker compose up -d starts the container left by the failed start, and that container has no port.
Additional Resources
- docker compose up (opens in a new tab), Docker’s reference: when Compose recreates containers, and
--force-recreate - docker compose ps (opens in a new tab), Docker’s reference: the containers of a project and their ports
- Port publishing and mapping (opens in a new tab), Docker’s guide: what a mapping such as
127.0.0.1:5678->5678means
Related
- How to Set Up and Run the Scheduled Daily Log for n8n
- How to Install n8n with Docker
- How to Update n8n in Docker
n8n, Docker and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by n8n GmbH or Docker, Inc.
0 comments