How to Disable Firewall on Ubuntu 18.04

By 

Updated on

3 min read

Disable UFW Firewall on Ubuntu

Ubuntu ships with a firewall configuration tool called UFW (Uncomplicated Firewall). UFW is a user-friendly front-end for managing iptables firewall rules and its main goal is to make managing firewall rules easier or as the name says uncomplicated.

It is highly recommended to keep the firewall enabled. However, in some situations, such as testing you might need to stop or disable the firewall.

In this tutorial, we will show you how to disable the UFW firewall on Ubuntu 18.04 systems.

Prerequisites

Make sure you are logged in as a user with sudo privileges .

Checking the Firewall Status

To view the current status of the UFW firewall, use the ufw status command:

Terminal
sudo ufw status

UFW firewall is disabled by default. If you have never activated UFW before, the output will look like this:

output
Status: inactive

Otherwise if the firewall is enabled you will see the following message:

output
Status: active

Disabling the Firewall

If you are disabling the firewall because you are experiencing connectivity issues or you have troubles configuring your firewall please check our guide about How To Set Up a Firewall with UFW on Ubuntu 18.04 .

To disable the UFW firewall on your Ubuntu system, use the ufw disable command:

Terminal
sudo ufw disable

The output will look like this:

output
Firewall stopped and disabled on system startup

The command above will stop and disable the firewall but it will not delete the firewall rules. The next time you enable the firewall the same rules will be loaded.

If you want to disable the firewall and delete all of the firewall rules use the ufw reset command:

Terminal
sudo ufw reset

You will be prompted whether you want to continue with the operation:

output
Resetting all rules to installed defaults. This may disrupt existing ssh
connections. Proceed with operation (y|n)? 
output
Backing up 'user.rules' to '/etc/ufw/user.rules.20190122_115214'
Backing up 'before.rules' to '/etc/ufw/before.rules.20190122_115214'
Backing up 'after.rules' to '/etc/ufw/after.rules.20190122_115214'
Backing up 'user6.rules' to '/etc/ufw/user6.rules.20190122_115214'
Backing up 'before6.rules' to '/etc/ufw/before6.rules.20190122_115214'
Backing up 'after6.rules' to '/etc/ufw/after6.rules.20190122_115214'

Resetting UFW firewall is helpful when you want to revert all of your changes and start fresh.

Enabling the Firewall

Before enabling the firewall, make sure that the SSH port is open for connection.

To enable the firewall run:

Terminal
sudo ufw enable

When asked type y to continue with the operation:

output
Command may disrupt existing ssh connections. Proceed with operation (y|n)?
output
Firewall is active and enabled on system startup

Conclusion

In this tutorial, you have learned how to stop and permanently disable the firewall on a Ubuntu 18.04 machine.

Most of the UFW commands are intuitive and easy to remember. For example, ufw status shows the status of the firewall and ufw disable disables the firewall.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page