-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker-compose up failing because "port is already allocated" #4950
Comments
|
Hi @shin- , I just did a hard reset on my machine and I get:
After that I have the same issue as posted by @PatrickConnors : Any ideas? |
@budnik Try running |
I ran into the same issue today (with a Both I may have found a solution, though: this is how my
and in my case the fix was simply to disable the port binding, that is changing the last part as:
Not sure if this is the right solution, nor if it can be generally applied to all use cases. Might it be an issue with
|
Solution above was what I needed, thanks a lot @lorenzo-pasa ! |
I was having the same issue after updating my docker-compose to 3.3 version. Below is part of my
|
I had this and also stuff like |
This 👇 works for me!!
|
ERROR: for iky_gateway Cannot start service iky_gateway: b'driver failed programming external connectivity on endpoint iky_gateway (47d83edbbc1568eae6d26f5e75931797b7e23c6528ff7cc8140f50811fb44922): Error starting userland proxy: Bind for 0.0.0.0:8080 failed: port is already allocated' I've tried |
Another solution that may be helpful to future readers is: double-check your docker-compose.yml file and check to make sure you don't have 2 items attempting to run on port 8080. If you do have 2 items configured to run on port 8080 you can get "port already allocated" error message for the service/container that is not causing the problem - which will cause you confusion when you try and kill the service/container and get no resolution to the error message. |
@Rub21's solution worked for me, except
|
I removed port binding and it worked for me, instead of doing |
docker stop $(docker ps -a -q) |
Same problem here. I am using docker version 17.05.0-ce, build 8965be, with docker-compose 1.13.0 and 1.22.0. The compose-yml file is 3.2. With apologies to @KazibweStephen , this is not a useful solution. You are telling docker-compose to pick an abritrary port for clients to connect to the container's mysql service. You might as well tell mysql not to listen to any port or just remove the port configuration altogether. I have tried various solutions above, including rebooting the server. No other containers are running, and there are no conflicts in the yml file. I recall that this worked in a much older version of docker/compose. If I completely reomve the I can see no reason vis-a-vis the documentation why the configuration does not work. The conclusion is there is something wrong with docker-compose's proxy setup. Unbelievable. I had, in fact, a tiny error which caused the problem. My configuration needed two ports, and one of these had a typo, replicating the other. facepalm |
Hi, when I run this, I got this message.. 98808d86b49cff5d stream 0 0 98808d86b6dd9be5 0 0 0 /tmp/.s.PGSQL.5432. Can you please help me what to do ? Thanks |
This fix worked for me.
|
I had a slightly different situation, posting here to record another case of this happening. When using a docker-compose.yml: ports:
- 8080:8080 docker-compose.override.yml: ports:
- 8080:8181 Perhaps this is an issue on its own, creating overriding mappings results in duplicate binding attempts. This situation is specifically narly because nothing is listening on the port until you attempt to bring the containers online. Which fails and therefor shuts down the entire composition, which results in the port becoming un-allocated again. |
The solution of @lorenzo-pasa worked for me! I'm using docker-compose and nginx, running ubuntu OS, thanks dude. |
I am curious: why is this issue closed, while numerous people still seem to encounter a problem(including myself)? Is the official fix to never write (for instance) |
@Ezwen agree
which exposes the port correctly. (vpnkit.exe is a part of Docker) I see that vpnkit.exe is listening to port 9001. So when I now try to start my Xdebug in PHPstorm it comes up with the error message I don't know why I can't tell the PHPstorm debugger to listen to port 9001 while it is always used by vpnkit.exe when I start my docker container? |
Otherwise `docker-compose up` throws an error about the port already being allocated. Per docker/compose#4950 (comment).
Thanks, @lorenzo-pasa ! That was exactly my problem and your solutions worked. I tried a lot of stuff to solve this with no result. Thank you, again!
|
For me the issue was another docker container was still running in the background from a different project. I fixed by running:
|
I have a same issue as @maritaria mentioned about. |
@freesoft It's probably best to open a new issue for this. |
I tried everything here but nothing seems to work then i did this: sudo lsof -i -P -n | grep 5432 kill all the processes then it worked for me. |
Had the same issue with
One of the |
I ran docker system prune (be cautious with this command) and then restarted docker, it worked for me. |
One potential solution for this is you don't always need to have an external port binding in your
Should be sufficient for postgres, as you only really want container <=> container interactions for development. (You shouldn't be shipping your DB in a container tho for production environments). |
I don't know if it will help someone, but nothing posted above helped me: All docker containers were stopped, no port in use in the system... I was astonished, and then, I found this in SO that did the trick: The issue is about restarting the docker service. As stupid as running:
And then, I was able to run the docker-compose back and all worked. |
Thanks! Pruning the network after docker-compose down was the thing that I missed by trying the previous answers. |
Yup
Yup, I can also confirm that this solved my issue! |
Have you had a solution for this problem? I just run into it the xdebug was working fine until yesterday evening then in storm: compose file:
All of which are working except the xdebug. All the solution what were mentioned here have been tried none of them works for me. The confusion is this was working in one secundes and suddenly stopped everything in the next one. |
In my case I had this problem because there were two replicas in my compose file:
When I've changed a number of replicas to one, docker-compose up started working |
I don't see why this issue has been closed. Pruning networks or forcefully restarting docker daemon is a workaround for a bug - it's not that the bug went away, it's just people embraced workarounds. This happens quite often on multiple machines and looks like a bug, though not an easy to reproduce one |
I had the same problem two times now.... |
Yes, My thought also is same as you. |
Doing this, then restarting docker engine & |
That's not really a solution in a production environment :-/ |
Fortunately I've never encountered this error on my production environment, only on my local dev env (macos). |
Thanks @olfamoussaoui, that work for me if you are using Windows you need to run the following command: |
what worked for me:
|
so I'm not sure if this is a fluke, but for some reason after I quit Spotify it seemed to work. I've tried most of the solutions above before that |
Yes, this works but make sure you know what 'launchctl' does (it stops docker but that doesn't clear up the problem per se as starting/stopping docker alone did not stop the error from reappearing). The important part is the 'docker rm' because it seems to remove the port allocation that docker is perceiving (likely deleting some reference in docker). For example, this 'docker-compose.yml' of mine (below) suddenly stopped launching with the error that port 5665 was already allocated even with no containers running in my system. docker compose down/stop/rm seemed to clear whatever was making docker think the port was already allocated.
|
I'm having this issue in Mentioned in #9117 |
If you use windows and if non of them worked, Delete your relevant container in Docker. Then right click on docker tray icon at the bottom right of the screen and close docker. Try run again. |
You saved my day |
I've got a port bound to the neighbor container! not the one which was provided in docker-compose file. But, in my case, another container is exposed silently, and it even does not show that in |
My problem was that I had a file called |
so basically i deleted container and restarted docker and that helped... |
My docker container is able to successfully build but when I enter the command docker-compose build, the following error is returned:
Here is my docker-compose.yaml
and here is the Dockerfile:
I don't believe I have another container running so I'm confused by the message Bind for 0.0.0.0:5432 failed: port is already allocated
The text was updated successfully, but these errors were encountered: