Error response from daemon: ports are not available: listen tcp 0.0.0.0:3306: bind: address already in use
Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use That was the nice surprise I got when I switched back to a project and wanted to start some docker containers using "docker-compose up -d" The context:
How to fixFirst check what is using the port 80 by running sudo lsof -i:80In my case I got: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 25348 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25349 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25350 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25352 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25353 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25354 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25355 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25356 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25357 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25358 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25359 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN) nginx 25360 gilbert_tchoi 6u IPv4 0xXXXXXXXXXXXXXXXX 0t0 TCP localhost:http (LISTEN)If you don't care, the brutal approach is taking all your PID and running them through kill -9 myPIDUnfortunately, the list of Nginx came back in my case with other PID. Random idea, let's check brew service by running brew services list nginx started root /Library/LaunchDaemons/homebrew.mxcl.nginx.plistCulprit found for the unkillable Nginx. To clean up this nginx service that was probably a leftover from another project, just run Now I can start my docker containers and get back to my work.
How can I start docker on Ubuntu 20.04, if it complains that address is already in use? I tried docker-compose up -d Starting relaatiotietokannat_db_1 ... Starting relaatiotietokannat_db_1 ... error ERROR: for relaatiotietokannat_db_1 Cannot start service db: driver failed programming external connectivity on endpoint relaatiotietokannat_db_1 (02444b3d0c2841a4fe702cf2705fbd5a869e44e7f258ecfbcea764ead989fcb4): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use ERROR: for db Cannot start service db: driver failed programming external connectivity on endpoint relaatiotietokannat_db_1 (02444b3d0c2841a4fe702cf2705fbd5a869e44e7f258ecfbcea764ead989fcb4): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use ERROR: Encountered errors while bringing up the project.
It’s a sunny day and you are starting your docker container when you get this message: “Cannot start container … bind: address already in use” … hmm, now what? Sometimes, when trying to start your docker instance, it’s possible to be stunted by another process using the same port. However, there are a few options you have in this situation. The ones I have tried and use when needed are listed here: To quickly move forward with successfully starting your container, you could just kill whatever is using the port. I usually do that but first check what is using the port, and, if it is non-essential at this time, kill it.
Option 2
Option 3
sudo /etc/init.d/apache2 restart sudo apachectl -k restart Option 4
When in Doubt
Always refer to the official Docker documentation. The Docker team have created additional resources, both free and paid, to supplement their product, and additional community support. Community support is fantastic! It allows developers from all across the world to collaborate and connect.
If you are new to Docker, have a look at their 101 tutorial here, and their learning programs here. Best of luck, and happy coding!
About Curious Minds |