↑ ↓ select, Enter open, Esc close

Close a port in ufw by deleting its rule

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
root@server
ufw delete allow 8080/tcp

Deletes the rule exactly as it was created, for IPv4 and IPv6. The specification must match the original rule, with or without protocol, exactly as when it was created. If the default deny policy applies afterwards, the port is closed.

Note: Never delete the rule for the SSH port this way while you are connected through it and no other rule allows access.

Also searched as

  • ufw close port
  • ufw delete allow rule
  • remove open port ufw

Related one-liners

All in Firewall

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.