I’m trying to run an Nginx container on my server using the following command:
docker run -d -p 80:80 nginx
But I keep getting this error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint <container_id>:
Bind for 0.0.0.0:80 failed: port is already allocated.
How can I find out what’s causing this and free up the port so I can run my container?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there,
That error means something is already using port 80 on your system. You can check which process is using it with:
sudo netstat -tulnp | grep :80
or
sudo lsof -i :80
If it’s Nginx or Apache, you can stop it:
sudo systemctl stop nginx
# or
sudo systemctl stop apache2
If you don’t want to stop the service, run your container on a different port, like this:
docker run -d -p 8080:80 nginx
Then access it at http://localhost:8080
.
Let me know if you’re still stuck! 🚀
- Bobby
Often this happens when a web server like Apache is pre-installed and running on the system. Disabling it using sudo systemctl stop apache2
(or httpd
, depending on the OS) usually solves the issue.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.