Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I turn off the firewall in Ubuntu 12.04?

Thanks for the answers. The reason for turning it off was twofold: I often cannot make a wireless connectin to internet and get the server is unable to connect message or I get a message that disappears telling me my domain is not compatible with the Avahi network whatever that is. So I thought if I disable firewall I would be ok.

So my question is as follows: What command line or configuration in Ubuntu 12.04 can I use to disable or stop the Ubuntu 12.04 default firewall?

share|improve this question
one problem per one post please. – Raja Feb 3 '13 at 0:55
I've removed one of your questions (based on the answer you received). If you still want to ask it, please ask it in a new question. – iBelieve Feb 3 '13 at 1:26
There isn't a firewall by default ( one is not needed ) so you will have to specify if you set one up, and if you know how to do that, you should know how to undo it. – psusi Feb 3 '13 at 3:20
@psusi I recommend posting something like that as an answer. – Eliah Kagan Feb 3 '13 at 5:38
@TheLordofTime "System" means (at least) two things. Do you mean every OS needs a firewall? Not every instance needs a one. As you say, Ubuntu's default firewall rules are permissive--it behaves like netfilter were unloaded from (or not compiled for/into) the kernel. This doesn't seem to cause security problems. Having ports closed when servers don't need to run is at least as effective as a firewall at preventing intrusion. If "stealth" mode is desired, a firewall is handy, but for WAN a NAT router is sufficient, and on LAN even a filtered node's layer 2 presence is often detectable. – Eliah Kagan Feb 3 '13 at 13:17

Actually Ubuntu got a firewall it self named uncomplicated firewall. For any reason you have problem with the firewall means you can simply disable it by running:

sudo ufw disable

from your terminal.

share|improve this answer
Note that ufw is only one way of configuring a firewall in Ubuntu so this would apply only if this was the method used. – thomasrutter Oct 25 '14 at 1:08
@ThomasW. No idea if that was true when you wrote that comment or not, but for me ufw was configured by default to block all incoming connections. Ufw wasn't enabled by default though, I had to manually enable it, so maybe that's what you meant? – Ajedi32 Jul 21 '15 at 13:55

sudo iptables -F will flush the firewall rules. You won't be able to turn off the firewall as it is built into the kernel.

share|improve this answer
What if you want to re-enable the rules later... say you're just disabling for a few minutes as a troubleshooting step. – Joel Coehoorn Mar 5 '15 at 20:30
Install iptables-persistent. Save your rules with /etc/init.d/iptables-persisten save. Then flush your iptables rules. To restore the rules restart iptables-persistent daemon. – jersten Mar 6 '15 at 4:00

By default, the firewall on Ubuntu (which can't be removed, because its part of the kernel) is unconfigured, and has default allow on everything. Unless you've added ufw or iptables rules, the firewall (which cannot be disabled because its part of the kernel) will not filter/block anything (Default ALLOW rule).

share|improve this answer
Thi was a real question because of my wireless connection not working properly. – dustbindiva Feb 5 '13 at 18:19
you should've commented on the question, not my answer. :/ – Thomas Ward Feb 5 '13 at 22:21

I had a problem that I can not access a server on my hosting machine (Ubuntu 14.04 64 Bit) from a guest windows machine by VMWare Player. I had been around for like a two days searching for a network solution while the problem was all about firewall.

I decided that it is all about firewall and I tried to see how to stop the firewall, I tried this solution : sudo ufw disable
didn't work with me, however I used another way

sudo service iptables stop

Then i tried to access the servers, and IT WORKS finally. Hope this helps

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.