Nginx does not listen on port 80

I just installed Ubuntu 12.04 server and nginx 1.2.7, deleted default from sites and added my own file to sites-available and a symbolic link to sites-enabled . Then restarted nginx.

Problem: However, when you go to the URL the site does not load. netstat -nlp | grep nginx netstat -nlp | grep nginx and netstat -nlp | grep 80 netstat -nlp | grep 80 both return no result! lsof -i :80 also returns nothing. A dig from another server returns the correct IP address, so it should not be a DNS problem. I managed to connect to apache, which I stopped right now. Nginx logs also show nothing.

How to fix this problem?

/etc/nginx/site-available/mysite.com

 server { listen 80; server_name www.mysite.com mysite.com *.mysite.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /var/www/mysite/public; index index.php index.html; location / { try_files $uri $uri/ /index.php?$args ; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_read_timeout 300; } } 
+63
linux ubuntu nginx
Apr 15 '13 at 17:45
source share
8 answers

I had the same problem, the solution was that I did not properly attach my siteconf file. Try running vim /etc/nginx/sites-enabled/mysite.com - can you get to it? I get "Permission denied."

If not run:

 rm /etc/nginx/sites-enabled/mysite.com ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/mysite.com 
+127
Sep 29 '13 at 23:21
source share

If your journals do not say anything about this issue, you cannot include a site-support directory. One easy way to say that the site is loading is to set the error / access log path within your server block to a unique path, restart nginx and check if the files are created.

Make sure that there is an include include directive in the http context in /etc/nginx/nginx.conf.

 http { ... include /etc/nginx/sites-enabled/*; } 
+26
Sep 25 '13 at 1:40
source share

I ran into the same problem, I got a Failed to load resource: net::ERR_CONNECTION_REFUSED when connecting via HTTP, but excellent on HTTPS. Ran netstat -tulpn and saw that nginx is not bound to port 80 for IPv4. Everything is done that is described here. It turned out that this is something very stupid:

Make sure the sites-available file with default_server indeed included.

Hope this saved a little of the other poor idiot a bit.

+6
Feb 03 '15 at 14:59
source share

You probably bind nginx twice to port 80. Is this your complete configuration file? Don't you have another statement while listening to port 80?

+4
Aug 16 '13 at 17:10
source share

I found it helpful to approach nginx debugging with the following steps:

1 ... Make sure nginx is running.

 ps aux | grep nginx 

2 ... Check the processes already associated with this port.

 lsof -n -i:80 

3 ... Make sure nginx has rebooted.

 sudo nginx -t sudo nginx -s reload 

On a Mac, brew services restart nginx not enough to restart Nginx.

4 ... Try creating simple answers manually to make sure the path to your location is not confused. This is especially useful when problems arise when using proxy_pass to forward requests to other running applications.

 location / { add_header Content-Type text/html; return 200 'Here I am!'; } 
+4
Nov 04 '18 at 4:11
source share

Half-column ; absent in /etc/nginx/nginx.conf for an example on the line before include /etc/nginx/servers-enabled/*; might just work around this construct, and checking nginx -t will succeed anyway.

So, just make sure that all commands in /etc/nginx/nginx.conf end with a semicolon ; .

+2
Dec 27 '16 at 20:52
source share

Have you checked if your nginx binary really exists? check

 #whereis nginx 

prints the binary path and checks this path using the init script from /etc/init.d/nginx. eg.

 DAEMON=/usr/sbin/nginx 

(In my init script, "test -x $ DAEMON || exit 0" is called, and in any case, this script returns nothing - my binary is completely missing)

+1
Aug 22 '13 at 14:58
source share

In my case, this network command output showed that nginx was correctly communicating with port 80, but the ports were not externally accessible or not visible with nmap .

Although I suspected a firewall, it turned out that the old iptables rules on the machine redirected traffic from these ports and clashed with nginx. Use sudo iptables-save to view all currently valid rules.

0
Apr 05 '19 at 8:01
source share



All Articles