Disable / Turn Off Firewall in Ubuntu Linux Server

How do I disable the firewall in Ubuntu Linux server edition? How do I turn off the firewall in Ubuntu Linux version 12.04 or 14.04 LTS server?

The latest version of Ubuntu comes with a program called ufw. It is used for managing a Linux firewall and aims to provide an easy to use interface for the user. [donotprint]
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements None
Est. reading time 2m

A Note About ufw

As I said earlier, the latest version of Ubuntu comes with ufw (now it is the default firewall configuration tool for Ubuntu). It is developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall.

List ufw firewall rules, enter:

$ sudo ufw status verbose
Sample outputs:

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip
To                         Action      From
--                         ------      ---- 80/tcp        ALLOW IN    Anywhere 80/tcp        ALLOW IN    Anywhere

To disable ufw based firewall, enter:

$ sudo ufw disable

List current firewall rules and stop firewall (old method)

You can type the following command to see if firewall is active or not (open a terminal or ssh session and type the following command):
$ sudo iptables -L -n
Sample outputs:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --             udp dpt:53 
ACCEPT     tcp  --             tcp dpt:53 
ACCEPT     udp  --             udp dpt:67 
ACCEPT     tcp  --             tcp dpt:67 
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --      state RELATED,ESTABLISHED 
ACCEPT     all  --           
ACCEPT     all  --             
REJECT     all  --             reject-with icmp-port-unreachable 
REJECT     all  --             reject-with icmp-port-unreachable 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

You can save existing firewall rules as follows:
$ sudo iptables-save > firewall.rules
Finally, type the following commands to stop firewall and flush all the rules:
$ sudo iptables -X
$ sudo iptables -t nat -F
$ sudo iptables -t nat -X
$ sudo iptables -t mangle -F
$ sudo iptables -t mangle -X
$ sudo iptables -P INPUT ACCEPT
$ sudo iptables -P FORWARD ACCEPT
$ sudo iptables -P OUTPUT ACCEPT

A note about GUI tools for Ubuntu desktop systems

You can also use GUI tool to enable or disable Firewall under Ubuntu Linux desktop edition by visiting System > Administration > Firewall configuration option:

Fig.01: Disabling Firewall In Ubuntu Linux

Fig.01: Disabling Firewall In Ubuntu Linux

Simply unselect “Enabled” option to turn off the firewall.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 6 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
6 comments… add one
  • raj Nov 25, 2011 @ 13:45

    pls give me solution for disable linux ubuntu version 2.24.1.

  • chandrasekharreddy Feb 23, 2012 @ 5:19

    #sudo ufw disable
    Firewall stopped and disabled on system startup.

  • medo Aug 12, 2013 @ 4:00

    hi , thanks for your great help

    i can connect via lan no problem but remotely always show an error messag
    a connection could not be established to the ppp server try reconnecting , if the problem continues , verify your setting
    and contact your administrator

    i follow all the steps
    what do u think where is the problem
    thanks again for u help

  • Andrew Aug 21, 2013 @ 22:32

    I ran that first command and it’s shown me the IP tables but they’re empty. Does this mean the firewall’s disabled or does it mean it’s running but effectively doing nothing? This should be on a pretty much OOB Ubuntu server 12.10.

  • Nick Sep 4, 2017 @ 12:25

    I’m very new to these settings and need a little help please? I’ve enabled the ufw in Ubuntu Server 16.04.3 LTS and allowed various ports such as, 22, 53, 80, 443, 445, 139, 8080 etc. Everything is working going through the firewall but browsers, IE Chrome and Vivaldi reports some dns problems. I would disable ufw and all is well and working again. Am I correct in enabling the ufw at all or should I leave it disabled, I’m a home user and not in any vast network environment? Any advice will appreciated. Thank you.

  • Wellington Torrejais da Silva Nov 26, 2017 @ 14:57


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum