LocalStack port 4566 already in use / bind conflict in CI
LocalStack binds its edge port 4566 on start. If another service, a leftover LocalStack container, or a service-container mapping already holds 4566, the bind fails and LocalStack never comes up.
What this error means
Starting LocalStack fails with "Bind for 0.0.0.0:4566 failed: port is already allocated" or "address already in use", so the health endpoint never responds.
LocalStack
Error response from daemon: driver failed programming external connectivity on endpoint localstack:
Bind for 0.0.0.0:4566 failed: port is already allocatedCommon causes
A leftover LocalStack container holds the port
A previous run did not clean up, so an old container still binds 4566 when the new one tries to start.
Another service mapped the same port
A different service container or process already published 4566, causing a bind conflict.
How to fix it
Remove leftovers and confirm the port is free
- Stop and remove any existing LocalStack container.
- Confirm nothing else listens on 4566.
- Start LocalStack again once the port is free.
Terminal
docker rm -f localstack 2>/dev/null || true
ss -ltn | grep 4566 || echo "4566 free"Map LocalStack to a different host port
If 4566 is genuinely needed by something else, publish LocalStack on another host port and point the endpoint URL at it.
Terminal
docker run -p 4577:4566 localstack/localstack:3
# then endpoint_url=http://localhost:4577How to prevent it
- Clean up LocalStack containers at the end of each job.
- Check that 4566 is free before starting LocalStack.
- Use a distinct host port if 4566 is reserved by another service.
Related guides
LocalStack "Could not connect to LocalStack health endpoint" in CIFix LocalStack "Could not connect to LocalStack health endpoint" in CI - tests started before LocalStack fini…
LocalStack botocore "Could not connect to the endpoint URL http://localhost:4566" in CIFix botocore "Could not connect to the endpoint URL http://localhost:4566" in CI - the AWS client reached for…
LocalStack "Ready." wait race (tests run too early) in CIFix LocalStack readiness races in CI - tests start before LocalStack logs "Ready." because a fixed sleep repl…