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:
- Mac os
- Laravel app built with Laradock including a Nginx docker image
How to fix
First 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.
Option 2
Option 3
Option 4
When in Doubt
About Curious Minds
We are a web development firm in New York and Chicago, providing development resources and consulting for websites and mobile apps since 2004.