curl or a monitoring probe while a browser shows the page fine is one of the most common false-comfort scenarios in hosting support. It almost always means the web server is not listening where the probe expects it to, and something else (a cache, a CDN, a proxy, or your browser itself) is papering over the gap.
What "Connection Refused" Actually Means
- The web server process is not running at all.
- The web server is running but bound to a different port (e.g., 8080 instead of 80).
- The web server is bound to a specific IP or to localhost (127.0.0.1) instead of all interfaces (0.0.0.0).
Verify Listening Ports with ss or netstat
ss is the modern replacement for netstat on Linux. Run this as root or with sudo:
BASH
ss -tlnp-t TCP, -l listening, -n numeric (no DNS resolution), -p show process name. Sample output format:
TEXT
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 511 127.0.0.1:8080 0.0.0.0:* users:(("nginx",pid=1234,fd=6))
LISTEN 0 511 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=1234,fd=7))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=800,fd=3))0.0.0.0 (all IPv4 interfaces), so external connections work. But port 8080 listens on 127.0.0.1 only, meaning connections from outside the server get refused.
If your system still has netstat (common on older CentOS boxes), the equivalent:
BASH
netstat -tlnpKey Things to Look For
127.0.0.1:80 or [::1]:80, the web server only accepts connections from the machine itself. Any external request, whether from curl on another machine, a monitoring probe, or a real visitor, gets refused. This is common when a reverse proxy setup is intended (e.g., Nginx in front of Apache on port 8080) but the front-end proxy is not running or not configured.
Bound to a specific IP that is not the one being queried. A server with multiple IPs might have Apache listening on 192.168.1.10:80 but not on the public IP 203.0.113.5:80. If DNS points to 203.0.113.5, external requests get refused even though the service is technically running.
Listening on a non-standard port. The web server might be on port 8443 instead of 443. A browser that previously visited the site might have a cached redirect or HSTS entry that sends it to the right port transparently. curl with no port override hits 443 and gets refused.
IPv4 vs IPv6 mismatch. If ss shows the server listening on :::443 (IPv6 only) but the DNS A record points to an IPv4 address, IPv4 clients get refused. Or vice versa. Check both 0.0.0.0 (IPv4 wildcard) and ::: (IPv6 wildcard) lines.
Why the Browser Showed It Working
curl pointed directly at the origin IP bypasses the CDN and hits the actual server, revealing the refusal.
DNS pointing somewhere else. Your local machine might have a different DNS cache or /etc/hosts entry than the monitoring server. The browser resolves the domain to IP-A (which works), while the monitoring probe resolves to IP-B (which does not). Verify with dig or nslookup from both locations.
HSTS or saved redirects. If the browser previously received an HSTS header or a 301 redirect, it may silently rewrite http:// to https:// or add a port number. curl does not remember previous responses unless you explicitly follow redirects with -L.
Reproduce the Problem Properly with curl
curl from outside the server (or from the server itself if testing localhost binding):
Test the exact IP and port, bypassing DNS and CDN:
BASH
curl -vk https://203.0.113.5:443/ -H 'Host: example.com'-v flag shows the connection attempt. -k skips certificate verification (useful for testing connectivity, not security). The -H 'Host: ...' header tells the web server which virtual host to serve.
If this returns "connection refused" but curl https://example.com works, something between the domain and the origin (CDN, proxy, load balancer) is absorbing the request before it reaches your server.
To test from the server itself whether localhost binding is the issue:
BASH
curl -v http://127.0.0.1:8080/curl -v http://YOUR_PUBLIC_IP:8080/ does not, the service is bound to localhost only.
Fixing the Bind Address
listen directive in your server block. listen 80; listens on all interfaces. listen 127.0.0.1:80; listens on localhost only. After changing, test config with nginx -t and reload.
For Apache, check Listen directives in the main config (typically httpd.conf or ports.conf depending on distro). Listen 80 binds all interfaces. Listen 127.0.0.1:80 binds localhost only.
For LiteSpeed, the listener configuration in the admin console or config XML controls which address and port it binds to.
Warning: If you are running a control panel like cPanel/WHM, Plesk, or similar, manual edits to web server configs may be overwritten on the next service restart or panel update. Check the panel's documentation for the correct way to change listener bindings. Some panels have specific include directories for custom configurations that survive restarts.
After making changes, re-run ss -tlnp to confirm the new binding took effect.
A Quick Verification Sequence
- Run
ss -tlnpon the server. Confirm the web server process appears and note the exact address and port. - Check whether it binds to
0.0.0.0/:::(all interfaces) or a specific IP /127.0.0.1. - From an external machine, run
curl -vkagainst the server's public IP on the expected port with the correct Host header. - Compare with
curl -vagainst the domain name to see if DNS or a CDN layer changes the result. - In the browser, hard-refresh and check DevTools Network tab for cached responses.
- If a firewall is in play, check
iptables -L -nornft list rulesetto rule out a DROP or REJECT rule on the port. (A firewall DROP causes a timeout, not "connection refused," but a REJECT rule does produce a refusal.)
ss and curl against the actual IP. They show you what the network sees, not what your cache remembers.