"No Route to Host" when making HTTP call to Linux server

I'm trying to configure a Linux server (NGINX) to allow HTTP requests through port 80 and it just doesn't seem to budge.

When I run curl localhost:80 from within the server, I get the correct response. But as soon as I change localhost to the public IP address, it gives the following error: curl: (7) Failed to connect to <ip> port 80: No route to host. Here are the things I've tried:

  1. ping <ip> works
  2. sudo ufw disable to temporarily disable the server firewall (I also added 80/tcp to my allowed ufw list. Output of sudo ufw status:
Status: active
To Action From
-- ------ ----
Nginx Full ALLOW Anywhere
OpenSSH ALLOW Anywhere
80 ALLOW Anywhere
443 ALLOW Anywhere
80/tcp ALLOW Anywhere
Nginx Full (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
  1. netstat -ltn shows port 80 being listened to:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN

If it helps, here is my NGINX configuration (and yes, NGINX is live XD):

upstream django { server 127.0.0.1:5000;
# server unix:///home/ubuntu/app/lyricschords/lyricschords.sock; #server unix:///home/ubuntu/lyrics-chords/lyrics-chords.sock;
}
server { listen 80; server_name 127.0.0.1 localhost <ip>; location /media/ { alias /home/ubuntu/app/lyricschords/media/; } location /static/ { alias /home/ubuntu/app/lyricschords/static/; } location / { uwsgi_pass django; include /etc/nginx/uwsgi_params; }
}

I also have Django running on port 5000 via uWSGI.

Any help would be greatly appreciated!

4

2 Answers

For anyone using Oracle, this post ended up solving things: . Turned out just to be a firewall issue

If localhost:80 works but the external IP does not, then the webserver is at least listening on port 80, but either it is listening on localhost only or it is firewalled on the public IP.

You can use tools like netstat -lt or ss -lt to get a list of ports being listend to, and look for *:http or [::]:http which indicates listening on the wildcard ip address. If instead you see 127.0.0.1:http then it is only listening on the local ip address. Or you can check your web server configuration.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like