Website Vidya
SecurityStep-by-Step Guide

How to Disable Firewall on Ubuntu 24.04

Complete guide on how to disable firewall on Ubuntu 24.04 LTS. Learn how to disable UFW, stop ufw.service, reset rules, flush iptables, and re-enable.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Disable Firewall on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Complete guide on how to disable firewall on Ubuntu 24.04 LTS. Learn how to disable UFW, stop ufw.service, reset rules, flush iptables, and re-enable.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Checking Current UFW Firewall Status
  • Step 2: Disabling UFW Firewall via Command Line
Grounded in full engineering runbookWebsiteVidya AI Engine

Interactive Builder for this Guide

Build your custom firewall syntax (How to Disable Firewall on Ubuntu 24.04)

Generated POSIX Command
sudo ufw allow port 443 proto tcp comment 'Production HTTPS'
UFW rule to ALLOW port 443/tcp.
Flag-by-Flag Breakdown
ufw allowallow matching inbound packets
port 443Match destination port 443
proto tcpFilter TCP transport traffic

The Uncomplicated Firewall (UFW) is the default packet filtering frontend interface pre-installed on Ubuntu Linux systems. Designed to streamline and simplify complex netfilter and iptables packet filtering rules, UFW provides a clean command-line interface for controlling incoming, outgoing, and routed network traffic on server and desktop environments alike.

While maintaining an active firewall is an essential pillar of Linux host security, there are legitimate administrative scenarios where completely disabling the firewall becomes necessary. Understanding how to disable firewall on ubuntu 24.04 is a vital troubleshooting skill when diagnosing network unreachable errors, port binding conflicts, container bridge issues, or cluster peering failures.

In this step-by-step tutorial, we demonstrate how to disable the firewall on Ubuntu 24.04 LTS (Noble Numbat). We cover checking active UFW status, deactivating the firewall with the standard CLI command, stopping and masking the underlying systemd service, inspecting and flushing kernel iptables chains, resetting corrupted rule configurations to factory defaults, and re-enabling firewall protection once troubleshooting is complete.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A server or desktop machine running Ubuntu 24.04 LTS.
  • A standard user account configured with administrative sudo privileges.
  • An active terminal session (either locally or through an active SSH connection).
  • Knowledge of alternative security controls (such as cloud provider security groups or VPC ACLs) if turning off the host firewall permanently.

Step 1: Checking Current UFW Firewall Status

Before modifying firewall states, verify whether UFW is currently active and inspect any existing port forwarding or filtering rules.

Run the sudo ufw status verbose command to check the operational state of the firewall.

Advertisement

If the status reports Status: active, UFW is actively filtering incoming packets according to your defined rules.

If the output reports Status: inactive, the firewall is already deactivated and not filtering network traffic.

# Check detailed UFW firewall status
sudo ufw status verbose

# View numbered rule list if active
sudo ufw status numbered

Step 2: Disabling UFW Firewall via Command Line

To immediately deactivate the firewall and allow all incoming and outgoing connections, execute the ufw disable command.

This command removes UFW's packet filtering hooks from the Linux kernel without deleting your custom configured rules or port policies.

Advertisement

Crucially, your existing rules remain stored in /etc/ufw/user.rules and /etc/ufw/user6.rules, ready to be restored whenever you re-enable the firewall.

Confirm the updated status by querying UFW.

# Deactivate UFW firewall
sudo ufw disable

# Confirm that UFW is inactive
sudo ufw status

Step 3: Stopping and Disabling the systemd UFW Service

Running sudo ufw disable persists across system reboots by setting ENABLED=no in /etc/ufw/ufw.conf. However, to guarantee that no background systemd units or orchestration tools restart the daemon unexpectedly, you can manage the service unit directly.

Stop the ufw.service daemon using systemctl.

Disable the service to prevent systemd from activating UFW at boot time.

Optionally mask the unit if third-party packages or automated scripts attempt to re-enable it during package updates.

# Stop the running UFW service daemon
sudo systemctl stop ufw

# Prevent UFW from starting on boot
sudo systemctl disable ufw

# Verify service unit status
sudo systemctl status ufw --no-pager

Step 4: Inspecting and Flushing Kernel iptables and nftables Chains

In certain advanced environments—especially servers running Docker, Podman, Kubernetes, or custom NAT routing scripts—packet filtering rules may persist in low-level iptables or nftables chains even after UFW reports inactive.

Inspect the active kernel filter table using sudo iptables -L -n -v.

If residual blocking rules remain and you require a completely open network stack for temporary troubleshooting, flush the filter table chains and set default policies to ACCEPT.

Always exercise caution when flushing iptables remotely over SSH to avoid dropping your active session.

# List active iptables filter rules
sudo iptables -L -n -v

# Set default policies to ACCEPT
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT

# Flush all rules and delete custom user chains
sudo iptables -F
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t mangle -F

Step 5: Resetting UFW Rules to Factory Defaults

If you want to clear out corrupted, conflicting, or legacy rules before disabling or re-architecting your firewall, use the UFW reset utility.

The sudo ufw reset command disables the firewall, backs up existing rules into /etc/ufw/, and restores default incoming deny and outgoing allow policies.

This is the recommended cleanup procedure when diagnosing why specific ports refuse to open.

# Reset UFW to factory default configuration (prompts for confirmation)
sudo ufw reset

# Check status after reset
sudo ufw status

Step 6: Alternative Best Practice: Opening Specific Ports Instead of Disabling

Completely disabling the firewall exposes all listening daemon ports (including internal databases like PostgreSQL, MySQL, Redis, and SSH) to the public internet.

In many cases, administrators only need to test a specific port (such as HTTP port 80, HTTPS port 443, or a custom application port like 8080).

Instead of turning off the entire firewall, you can temporarily permit traffic on the exact port required for testing, and delete the rule once tests conclude.

# Allow a specific application port temporarily
sudo ufw allow 8080/tcp comment 'Temporary test port'

# Verify newly added rule
sudo ufw status numbered

# Delete the test rule by number once testing is done
sudo ufw delete 1

Step 7: Testing Network Connectivity After Disabling Firewall

After disabling UFW, verify that network packets are no longer blocked and your desired network sockets accept incoming TCP/UDP connections.

Test connectivity from an external workstation using nc (netcat), curl, or nmap.

On the server itself, verify that your application is listening on 0.0.0.0 (all interfaces) rather than being bound strictly to 127.0.0.1 (localhost loopback).

# Verify listening network ports and binding addresses
sudo ss -tulpn

# Test connection from external machine
# nc -zv <server_ip_address> 80

Step 8: Re-enabling and Restoring Firewall Protection

Once you have finished troubleshooting connectivity issues, you should promptly re-enable the firewall to safeguard your Ubuntu server against unauthorized port scanning and brute-force intrusion attempts.

Before activating UFW, always ensure that your SSH port (default port 22) is permitted to prevent locking yourself out of remote cloud servers.

Enable UFW and verify that your protected rules are once again actively enforced.

# Ensure SSH port is permitted prior to re-enabling
sudo ufw allow OpenSSH

# Re-enable UFW firewall
sudo ufw enable

# Verify active status and enforced rules
sudo ufw status verbose

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Command 'sudo ufw disable' hangs or does not return immediately

Resolution: This can occur if an underlying netfilter or iptables kernel lock is held by Docker or another networking daemon. Run sudo systemctl stop docker temporarily, execute sudo ufw disable, and restart Docker.

Locked out of SSH session after re-enabling firewall

Resolution: Access your server via cloud web console (VNC/serial console) and execute sudo ufw allow 22/tcp && sudo ufw reload. If using a custom SSH port, ensure you explicitly allow that port number.

Ports remain unreachable even after UFW status shows inactive

Resolution: If UFW is disabled but packets are still dropped, inspect cloud provider security group rules (AWS Security Groups, DigitalOcean Cloud Firewalls, or GCP VPC firewall rules) which filter traffic before it reaches the Ubuntu operating system.

Security Best Practices and Hardening

Never leave a production server's firewall permanently disabled if it possesses a public IPv4 or IPv6 internet address.

If you must disable host UFW due to Docker conflicts, ensure perimeter network security groups (AWS, Azure, or GCP firewalls) enforce strict ingress filtering.

Always confirm that the SSH port is allowed before executing 'sudo ufw enable' to prevent accidental administrator lockout.

Monitor unauthorized connection attempts using fail2ban or intrusion detection systems (IDS) alongside active firewall policies.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
No. Running sudo ufw disable simply unloads packet filtering from the Linux kernel. Your custom rules remain saved in configuration files and will be automatically restored whenever you run sudo ufw enable.
No. On fresh installations of Ubuntu 24.04 LTS Desktop and Server, UFW is pre-installed but set to inactive by default until an administrator explicitly enables it.
Execute sudo iptables -L -n -v for IPv4 and sudo ip6tables -L -n -v for IPv6 to inspect the raw netfilter packet filtering chains directly in the Linux kernel.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout