HTTP Request to Port 80 Not Returning as Expected

Guide for Handling NGINX Port 80 HTTP Requests in Linux


You try to connect via HTTP request to port 80 to NGINX using e.g. the below command on the same machine running the NGINX service, but don't get the website that NGINX should provide as the reponse:

curl http://localhost

What to check

  • If you get a website in return but it doesn't seem to be from NGINX: Many distributions deploy some webserver (or another service) already by default, which listens on port 80. Check if you might already have other webservers running on your system like Apache, which sometimes is bundled and installed by default with certain Linux distributions, that might be listening on TCP port 80 (occupying this port). Then make sure to disable their service or uninstall those or alternatively change the port for your web application in the NGINX configuration to another port different than port 80.

  • If you don't get any response: Use following command to check if your current NGINX configuration is valid: nginx -t

  • Check if the NGINX service is running service nginx status

  • Check if port 80 is open on your system by running: netstat -ano | grep :80

  • Check on which ports NGINX is listening: netstat -anpe | grep nginx

Note that commands above might be slightly different in your specific environment.

For more details check the official NGINX documentation.

Last updated