The web server on an Oracle Cloud Always Free instance cannot be reached on port 80
The 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.
Fix it fast
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://localhost2Match what you see, then jump to its fix
- 1
curl 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
the console rule exists and the request still times outThe instance firewall (iptables) drops the trafficFix - 3
curl http://localhost fails, or works only on another portnginx listens on a different address or port than you are callingFix
- 1
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 Rules2Fix
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: 803Verify
Request the public IP again from your own computer.
curl -I http://<public-ip>Confirmed by docs.oracle.com
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-numbers2Fix
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 save3Verify
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
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://localhostConfirmed by nginx.org
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
Servers
A Let's Encrypt certificate did not renew with Certbot
Type: connection ... Timeout during connect (likely firewall problem)
Run sudo certbot renew --dry-run and read the Type and Detail lines.
6 causes, each with a fixServers
curl cannot connect to port 80 or 443 on a server running nginx
CURLE_COULDNT_CONNECT (7): Failed to connect() to host or proxy
Exit code 7 means the TCP connection itself failed, before any HTTP happened.
3 causes, each with a fixServers
Django returns a 500 behind Gunicorn and the traceback is nowhere
The traceback shows locally with runserver but not under Gunicorn
With DEBUG set to False, Django's default logging does not print errors to the console.
2 causes, each with a fixServers
Your website on a Google Compute Engine VM times out on port 80
The site works with curl on the VM but not from outside
A timeout, as opposed to a refusal, usually means a firewall dropped the packets.
3 causes, each with a fixServers
Gunicorn rejects a request with "Error parsing headers: limit request headers fields size"
Error parsing headers: 'limit request headers fields'
Gunicorn caps the size of one header field at 8190 bytes and the number of headers at 100 by default.
2 causes, each with a fixServers
HAProxy answers 503 "No server is available to handle this request"
No server is available to handle this request.
HAProxy sends 503 when it has no server to give a request to.
4 causes, each with a fix