UFW is blocking Docker ports

There is a fair amount of info out there about Docker over-riding UFW seetings, e.g. UFW is set to block all ports but spinning up a Docker container will allow traffic on a port. DO Support have pointed me towards guidance on this.

However, I am running into the opposite problem: if UFW is enabled, I cannot get to my Docker port. If UFW is disabled, I can get to my Docker port just fine. I would prefer to have UFW enabled and I have used: ufw allow <port-number> … but this is not helping.

Any idea what I need to do?


Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
August 6, 2023

Heya @esimms999,

Allowing the port via ufw should work. Are you sure that’s the only port needed by Docker?

Bobby Iliev
Site Moderator
Site Moderator badge
August 5, 2023


I’ve ran into the exact same issue a couple of days ago.

What worked for me was to restart Docker with sudo systemctl restart docker.

If this does not help, do you by any chance have any other firewalls like CSF or a DigitalOcean Cloud firewall?

Also, if restarting Docker does not fix the issue, can you confirm the OS that you are using and the Docker version so I could try to reproduce this on my end and further investigate it?



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel