← Home  |  PacketUtils

Open Port 80 on Ubuntu with iptables

Five steps from a closed port to a tested, saved rule. Pick your ports and the commands update.

1. Check whether ufw is active

Ubuntu ships ufw disabled. If the status is inactive, continue with step 2. If it is active, do not mix in raw iptables rules; run the ufw command instead and skip to step 5:

2. Look at the current rules

Note where a REJECT rule sits. Your new rule must go above it, which is why the next step inserts at position 1.

3. Add the rule

4. Save it so it survives a reboot

5. Test it

The first command shows that a web server is listening; if nothing is, opening the port changes nothing. Then test from another machine. On a cloud server the provider firewall must allow the port too, for example on Oracle Cloud. More on saving: how to save iptables rules.

FAQ

Is port 80 open by default on Ubuntu?

Ubuntu does not block it by default, but many cloud images add a firewall rule that does. Check with iptables -L and your provider settings.

Do I also need to open port 443?

Yes, for HTTPS. Choose the 80 and 443 option and the commands cover both.

Why can I not reach my site after opening port 80?

Either nothing is listening on the port, the rule sits after a REJECT rule, or the cloud provider firewall still blocks it.