How to Safely Bypass Ubuntu ‘UFW Default Deny’ (Open a Specific Port for Gaming)

Ubuntu Linux includes an incredibly powerful, built-in firewall known as UFW (Uncomplicated Firewall). By default, UFW is configured with a strict “Default Deny” policy for all incoming traffic. This means if you start a local Minecraft server, a web server, or attempt to host a peer-to-peer gaming lobby, your friends will not be able to connect to you. The firewall instantly drops their incoming packets.

You do not need to turn off the entire firewall and expose your computer to the entire internet just to play a game. You can safely bypass the default deny block by punching a highly specific “pinhole” through the firewall for the exact port your game requires.

How to Safely Bypass the Ubuntu UFW Default Deny Block

You must use the terminal to add an explicit “allow” rule to the firewall configuration.

  1. Open your Terminal application (Ctrl + Alt + T).
  2. First, verify that UFW is actually active. Type this command and press Enter: sudo ufw status
  3. If the terminal says “Status: active”, proceed to the next step.
  4. You must know the exact port number your game or application uses. For example, a standard Minecraft server uses port 25565.
  5. To punch a hole through the firewall specifically for that port, type the following command (replace 25565 with your actual port number): sudo ufw allow 25565/tcp
  6. Press Enter. The terminal will respond with “Rule added.”
  7. If your game uses UDP instead of TCP (which is common for fast-paced shooters or voice chat), you must also add a UDP rule: sudo ufw allow 25565/udp
  8. Finally, force the firewall to reload its configuration by typing: sudo ufw reload

Your friends can now successfully connect to your hosted server. The UFW firewall remains active and will continue to aggressively block all other incoming hacking attempts, keeping your system safe while allowing your specific game traffic to pass through unharmed.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.