How To Reset the Firewall on Ubuntu 16.04 & 18.04 LTS Server

Reset Firewall Ubuntu


eset Firewall Ubuntu 18.04: Resetting firewall will helps you to manage the incoming and outcoming traffic to your server. By using a Firewall, You can close any unwanted ports and essential ports to your server. The most commonly accessing ports of the servers are “Port 80, Port 443 & Port 22“. To reset the Firewall settings you will need a DigitalOcean droplet running Ubuntu 18.04 or Ubuntu 16.04 and you will additionally need an SSH or Putty Software to access the Droplets.

Jump To:

Needs of Firewall Resetting:

Sometimes you may not be allowed to connect to your website or your droplet. This is due to the firewall disabled your incoming request to your droplet. Actually, you need to adjust the Firewall setting to default state to prevent the incoming and outgoing traffic request from your server. Resetting the firewall to a default state and allowing connections through to the ports you are trying to access may resolve the issue or rule out the firewall as a potential source.

Disabling UFW:

In Ubuntu 16.04 or 18.04, UFW is expanding as “Uncomplicated Firewall“. You need to disable and reset the firewall and permitting the firewall to allow all connections through the most common parts.

You need to disable the UFW by using the following command.

$sudo ufw --force disable

By implementing the above command, you will able to connect to your server through the SSH connection If you are facing still any issues in connecting to your server and then you need to do some more resetting options for a firewall.

Check this too  Doctl Ubuntu- How to Install DigitalOcean Command Line Tool on Ubuntu 18.04 LTS/ 19.04

Resetting UFW:

$sudo ufw --force reset
By implementing the above command, The UFW will remove all existing rules of Firewall and allow us to start from scratch.

Deny All Incoming Request:

$sudo ufw default deny incoming

The above command will deny all your Incoming Request to your server. We will define the ports in the below steps and follow the below steps to enable the Ports.

Allow All Outgoing Request:

$sudo ufw default allow outgoing

The above command will allow you enabling the outgoing traffic from your server to the outside world.

Defining Ports:

The command to add a port through remains the same, only the port will change.

  • SSH – Port 22
  • HTTP – Port 80
  • HTTPS – Port 443

Allow TCP connections on Port 22:

$sudo ufw allow 22/tcp
Allow TCP connections on Port 80:

$sudo ufw allow 80/tcp
Allow TCP connections on Port 443:

$sudo ufw allow 443/tcp

Enabling UFW:

$sudo ufw --force enable

The above command will help you to enable the UFW to your server. This will allows an incoming and outgoing request to your server.


That’s it, friends. This article will help you reset the firewall settings to your server on Ubuntu 16.04 or Ubuntu 18.04 server. If you have any queries and then feel free to comment on us.

Leave a Reply

Your email address will not be published. Required fields are marked *

Written by Jim Moriarty

Hello, Am Jim from Arizona, Big Fan of Holmes. Server-side handler, Network Engineer & currently working for Tec Robust. I write a server-based article.

Contact me:
tecrobust [@]
Sub: Message to Jim.

Gnome System Monitor

How to Install Gnome System Monitor on Ubuntu 18.04 & 19.04

Shutdown Ubuntu Command

Linux Shutdown Commands- How to Shutdown Ubuntu & More using Terminal