Cybersecurity Updates & Tools

Disable UFW Firewall on Ubuntu 18.04: Stop, Reset, and Re-enable

UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules on Ubuntu. It ships pre-installed and simplifies tasks that would otherwise require writing complex iptables commands by hand. UFW is the standard way to control inbound and outbound traffic on Ubuntu servers.

Keeping the firewall enabled is strongly recommended for any server exposed to the internet. That said, there are legitimate reasons to disable it temporarily — troubleshooting a connectivity issue, testing network behavior without firewall interference, or migrating to a different firewall solution.

This guide shows you how to disable the firewall on Ubuntu 18.04, how to reset all rules when you want to start fresh, and how to safely re-enable it when you are done.

<strong>Prerequisite:</strong>&nbsp;You need sudo access.

Disable Firewall on Ubuntu: Check Status and Stop UFW

Before making any changes, check the current state of the firewall:

bashsudo ufw status

If UFW has never been activated, the output is:

Status: inactive

If UFW is running, you see:

Status: active

An active status also lists all the rules currently in effect, including which ports are allowed and from which sources.

Disable UFW. To stop the firewall and prevent it from starting at boot, run:

bashsudo ufw disable

The output confirms:

Firewall stopped and disabled on system startup

This is an important distinction: ufw disable stops the firewall and removes it from the startup sequence, but it does not delete any of your rules. All your existing allow and deny rules are preserved in the configuration files. The next time you run sudo ufw enable, those same rules load automatically without any extra setup.

Use ufw disable when you need the firewall off temporarily and plan to turn it back on later.

Reset UFW Rules and Start Fresh with ufw reset

ufw reset is different from ufw disable. It does not just stop the firewall — it deletes all of your custom rules and reverts UFW to its default state. This is the right command when you want to wipe your firewall configuration and start over from scratch.

Run:

bashsudo ufw reset

UFW asks you to confirm before proceeding:

Resetting all rules to installed defaults. This may disrupt existing sshconnections. Proceed with operation (y|n)?

After you type y, UFW backs up your existing rule files before deleting them. The backup filenames include a timestamp, for example:

Backing up 'user.rules' to '/etc/ufw/user.rules.20190122_115214'

These backups are stored in /etc/ufw/ and can be restored manually if you change your mind. After a reset, UFW is disabled and all previously configured ports are closed.

Note: After a reset, do not run ufw enable before adding an allow rule for SSH (port 22). Enabling the firewall without an SSH rule will lock you out of a remote server immediately.

Re-enable the UFW Firewall and Verify It Is Active

When you are ready to turn the firewall back on, make sure SSH access is allowed first. If your SSH rule was wiped by a reset, add it back before enabling:

bashsudo ufw allow OpenSSH

Then enable the firewall:

bashsudo ufw enable

UFW asks for confirmation because enabling it can interrupt existing SSH sessions:

Command may disrupt existing ssh connections. Proceed with operation (y|n)?

Type y and the firewall activates:

Firewall is active and enabled on system startup

Run sudo ufw status to confirm the firewall is running and to review the active rules. If you used ufw disable earlier (not ufw reset), your original rules are already loaded and no further setup is needed.

The UFW firewall is now under your control on Ubuntu 18.04. For a full guide on setting up rules, managing ports, and configuring allowed IP ranges, read the UFW setup guide for Ubuntu 18.04. Leave a comment below if you run into any issues.