Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

The web server on an Oracle Cloud Always Free instance cannot be reached on port 80

ErrorThe browser waits and then times out on http://<public-ip>

Short answer

On Oracle Cloud a port has to be open in two places: the network rules of the subnet or network security group, and the firewall inside the instance. Test with curl on the server itself first. If that works, add the ingress rule in the console, then insert an iptables rule and save it.

  • Applies to Oracle Cloud Infrastructure Always Free, Ubuntu 24.04, nginx 1.26
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run this on the instance. If it returns a response, nginx is fine and the block is in the network or the firewall. If it fails, fix nginx first.

    curl -I http://localhost
  2. 2Match what you see, then jump to its fix

    1. 1curl on the server works, but the request from outside only times outNo ingress rule for the port in the subnet's security list or NSGFix
    2. 2the console rule exists and the request still times outThe instance firewall (iptables) drops the trafficFix
    3. 3curl http://localhost fails, or works only on another portnginx listens on a different address or port than you are callingFix

What does the error look like?

  • The browser waits and then times out on http://<public-ip>
  • curl http://localhost on the instance works, but the same request from outside does not

Cause 1 of 3

No ingress rule for the port in the subnet's security list or NSG

1Check

Security rules are set on the subnet through its security list, and on resources through network security groups. Oracle's docs say to check the NSGs the instance is in, the security lists of its subnet, and the instance's own firewall together.

# Console: Networking > Virtual Cloud Networks > your VCN > subnet > Security Lists > Default Security List > Ingress Rules

2Fix

Add an ingress rule. Oracle's Ubuntu tutorial uses source CIDR 0.0.0.0/0, protocol TCP, destination port range 80, and leaves the source port range empty.

Source Type:            CIDR
Source CIDR:            0.0.0.0/0
IP Protocol:            TCP
Source port range:      (blank)
Destination port range: 80

3Verify

Request the public IP again from your own computer.

curl -I http://<public-ip>

Confirmed by docs.oracle.com

Did this fix it?

Cause 2 of 3

The instance firewall (iptables) drops the traffic

1Check

Oracle's Ubuntu tutorials open the port with an iptables rule inside the instance as well. List the INPUT chain with numbers and look at where rules that reject or drop traffic sit.

sudo iptables -L INPUT -n --line-numbers

2Fix

Insert the rule at a position above those rules (an append with -A goes to the end of the chain). Oracle's tutorial inserts at position 6 on its image; use the number that fits your list. Then save so it survives a reboot.

sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPT
sudo netfilter-persistent save

3Verify

Check the rule appears, then request the site from outside.

sudo iptables -L INPUT -n --line-numbers
curl -I http://<public-ip>

Confirmed by docs.oracle.com

Did this fix it?

Cause 3 of 3

nginx listens on a different address or port than you are calling

1Check

Without a listen directive nginx uses *:80 when it runs as root and *:8000 otherwise. A listen 127.0.0.1:80 line only accepts local traffic.

sudo ss -ltnp | grep nginx
sudo nginx -T 2>/dev/null | grep -n "listen"

2Fix

Use a listen line without a loopback address for the public site, then reload.

server {
    listen 80;
    server_name _;
}

3Verify

Test the config, reload, and repeat the localhost request.

sudo nginx -t && sudo systemctl reload nginx
curl -I http://localhost

Confirmed by nginx.org

Did this fix it?

How do I stop it coming back?

  • Treat every new port as a two-step job: console rule first, instance firewall second.
  • Run curl against localhost before blaming the network.
  • Save iptables changes with netfilter-persistent so a reboot does not remove them.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.