To remove a firewall on Ubuntu you have two levels: sudo ufw disable turns UFW off but keeps it installed and ready, while sudo apt remove ufw uninstalls it entirely. Nine times out of ten disable is what you actually want - it stops the firewall from filtering without throwing away your rules, so you can turn it back on in one command. Fully removing it is for the specific case where you are switching to another firewall (raw iptables, nftables, or a cloud-level firewall) and need UFW out of the way. What you should almost never do is remove the firewall and leave an internet-facing box with nothing filtering it at all.
“Remove the firewall” is usually the wrong request behind a real one: something is being blocked and you want it to stop. Disabling temporarily is the safe way to test that theory without stripping the box bare.
Table of contents
- Disable vs remove: pick the smaller hammer
- Disabling UFW the reversible way
- Fully removing UFW
- The mistake: leaving a server naked
- Other firewalls: firewalld and iptables
- How this fits the rest of the stack
- FAQ
Disable vs remove: pick the smaller hammer
UFW (Uncomplicated Firewall) is the default firewall front-end on Ubuntu, and there are two very different things people mean by “remove” it:
- Disable -
sudo ufw disable. UFW stops filtering traffic immediately, but it stays installed and remembers all your rules.sudo ufw enableturns it straight back on. This is reversible and safe. - Remove/uninstall -
sudo apt remove ufw. The package is gone. Your rules go with it. Reinstalling means configuring from scratch.
Start with disable. If you are troubleshooting whether the firewall is what is blocking a connection, disabling proves it in seconds and you can re-enable just as fast. Uninstalling to test a theory is like demolishing a wall to check if a door was locked.
Disabling UFW the reversible way
To turn the firewall off without losing anything:
sudo ufw disable
sudo ufw status
status should now report inactive. Traffic is no longer filtered by UFW. Your rules are still stored - sudo ufw status verbose shows them even while inactive - so re-enabling restores exactly the setup you had:
sudo ufw enable
If you want to keep the firewall on but clear its rules and start fresh, sudo ufw reset wipes the rules back to defaults without uninstalling anything. That is the middle ground: firewall present, rules blank. Between disable, reset, and enable you can do almost anything people reach for “remove” to accomplish, all reversibly.
Fully removing UFW
If you genuinely need UFW gone - usually because you are moving to nftables or managing rules directly with iptables - uninstall it:
sudo ufw disable
sudo apt remove ufw
Disable it first so it is not active during removal. If you want its config files gone too:
sudo apt purge ufw
One caveat: removing UFW does not automatically flush the underlying iptables rules it created. Depending on your system, some rules may linger until reboot or until you flush them manually with sudo iptables -F. After removing UFW, check what is actually in place with sudo iptables -L so you know whether the box is now wide open or still carrying leftover rules. Do not assume uninstalling the front-end cleared the back-end.
The mistake: leaving a server naked
Here is the part that matters. On a cloud VM or any internet-facing server, removing the firewall and walking away leaves every listening service exposed directly to the internet - SSH, databases, admin panels, whatever is bound to a public interface. Automated scanners find open ports within minutes, and an unprotected database or a brute-forceable SSH is exactly what they are looking for.
So if you remove or disable the host firewall, make sure something is still filtering:
- A cloud provider firewall / security group at the network level (often the better place to enforce rules anyway).
- Or re-enable the host firewall once you have finished whatever you removed it for.
Removing the firewall to fix a connectivity problem, then forgetting to restore protection, is how boxes get compromised. Turn it off to test; do not leave it off to forget.
Other firewalls: firewalld and iptables
UFW is Ubuntu’s front-end, but you may be on a system using something else:
- firewalld (Fedora, RHEL, CentOS): disable with
sudo systemctl stop firewalldand prevent it starting at boot withsudo systemctl disable firewalld. Remove withsudo dnf remove firewalld. - Raw iptables/nftables: there is no package to remove in the same sense - you flush the rules with
sudo iptables -F(and set the default policies back toACCEPTif you had changed them). But flushing toACCEPTon a public box is exactly the “naked server” risk above.
Whichever tool you are on, the principle holds: disabling is reversible and safe for testing; removing is for switching tools; and an internet-facing machine should never be left with nothing filtering it. Match the action to the actual reason you wanted the firewall gone.
How this fits the rest of the stack
Whatever you decide here, the cost of it eventually shows up as a bill. The RunxBuild hosting calculator is the right place to model that before committing: the compute, the database, the storage, the bandwidth, the worker - each one is a separate line item, and the real cost of a platform is the sum, not the headline number. The RunxBuild dashboard is where the team sees the actual usage once it is running.
Useful related references:
- Allow Chrome Through Your Firewall: Windows, macOS, and Linux
- Cloud Managed Firewall: What It Does, What It Doesn’t, When to Use One
- Remove Directory Linux Not Empty: rm -rf, find -delete, and Safety
- Database network security on RunxBuild
FAQ
How do I remove a firewall on Ubuntu?
You have two levels. sudo ufw disable turns the firewall off but keeps it installed and remembers your rules, which is reversible with sudo ufw enable. sudo apt remove ufw uninstalls it entirely. Prefer disable unless you are specifically switching to another firewall tool.
What is the difference between disabling and removing UFW?
Disabling (ufw disable) stops filtering but keeps UFW installed with its rules intact, so you can re-enable in one command. Removing (apt remove ufw) uninstalls the package and discards the rules. Disable is the safe, reversible choice for testing; remove is for permanently switching firewall tools.
Is it safe to remove the firewall from a server?
Not on an internet-facing server unless something else is filtering traffic. Removing the firewall exposes every listening service - SSH, databases, admin panels - to automated scanners that find open ports within minutes. If you remove the host firewall, enforce rules at the cloud provider’s security-group level instead.
Does removing UFW clear the iptables rules?
Not always. UFW manages underlying iptables rules, and uninstalling the front-end may leave some rules in place until reboot or a manual flush. After removing UFW, run sudo iptables -L to see what remains and sudo iptables -F to flush if needed - but flushing on a public box removes your protection.
How do I temporarily turn off the firewall to test something?
Use sudo ufw disable, run your test, then sudo ufw enable to restore it - your rules are preserved throughout. This proves whether the firewall is what is blocking a connection without uninstalling anything. Re-enable as soon as the test is done so the box is not left unprotected.