Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use

Tags:

docker

ubuntu

I am trying to follow a tutorial for Docker beginners (https://docs.docker.com/get-started/)

When I try to run this command: $ docker run -d -p 80:80 docker/getting-started

I get this Error:

docker: Error response from daemon: driver failed programming external connectivity on endpoint suspicious_murdock (863f389a032ea76d187c4387701b9eb0b6d4de4d0a9ed414616fa6b4715346ab): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use.

I tried removing all the dockers docker rm -fv $(docker ps -aq) but it did nothing.

What can I do?

like image 322
Borybar Avatar asked Sep 03 '25 05:09

Borybar


2 Answers

I had to stop apache2 from running on port :80 - sudo service apache2 stop

like image 112
Borybar Avatar answered Sep 04 '25 19:09

Borybar


why is this error showing?

This error means that you have a process listening to port 80 (the default HTTP port). This is probably a server of some sorts like apache/nginx/lighttpd.
Other answers suggest closing a database (mysql/mariadb), but - if configured correctly - they will be using a different port (most often 3306). This means that stopping your database will probably not solve the issue, since they are not using port 80.

how to find out what is causing this?

from here:
In a terminal type (with sudo, so it also shows root processes):

sudo lsof -i :80

you should get something like this:

COMMAND     PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
lighttpd   1713   www-data    4u  IPv6  36989      0t0  TCP *:http (LISTEN)
lighttpd   1713   www-data    5u  IPv4  36990      0t0  TCP *:http (LISTEN)
firefox-b 23384  your-user  150u  IPv4 122957      0t0  TCP pop-os:37322->ef-in-f94.1e100.net:http (ESTABLISHED)
firefox-b 23384  your-user  174u  IPv4 122155      0t0  TCP pop-os:37314->ef-in-f94.1e100.net:http (ESTABLISHED)

Note the (LISTEN) vs (ESTABLISHED) at the end. (LISTEN) is the culprit here, caused by the command lighttpd, which is a server. Also, the USER of lighttpd is www-data, which is not you, so it would not show without sudo.

Now, to stop it, use:

sudo service stop lighttpd

where you replace lighttpd with whatever the command is (of course you kind of want to know what you're doing here, since you don't accidentally want to pull your website offline).

like image 23
Fee Avatar answered Sep 04 '25 20:09

Fee