hxhking
hxhking

Reputation: 21

Error "Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE) in Docker

I tried to run an nginx server on my Mac with:

docker container run --publish 80:80 nginx

It is returning this error.

docker: Error response from daemon: driver failed programming external connectivity on endpoint hungry_shtern (88e68bd0a448ebe25a62c1c897d38a58e7cc581736ea55a0b764197d0416fce6): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE).

How to fix this?

Upvotes: 0

Views: 3547

Answers (2)

saulR
saulR

Reputation: 109

As other answers pointed, that port is already in use by some other service.

This service is the default apache installed on mac.

To confirm, try:

sudo lsof -i:80

And if you see the command httpd appearing there, the apache server is running, and using port 80.

You could also just try to access http://localhost:80 on your browser. If the apache server is running, you'll see something like "It works!".

To disable this service:

sudo apachectl -k stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

After the first command you will be able to bind that port with docker. After the second, you'll disable apachectl on startup.

Upvotes: 1

spqa
spqa

Reputation: 186

Maybe port 80 is in use by another process, you need to kill that process or change bind port of docker container:

docker container run --publish 8080:80 nginx

Upvotes: 0

Related Questions