nginx not listening to port 80

前端 未结 10 1957
长发绾君心
长发绾君心 2020-12-12 23:56

I\'ve just installed a Ubuntu 12.04 server and nginx 1.2.7, removed default from sites-enabled and added my own file into sites-available and symli

相关标签:
10条回答
  • 2020-12-12 23:58

    I had this same problem, the solution was that I had not symlinked my siteconf file correctly. Try running vim /etc/nginx/sites-enabled/mysite.com—can you get to it? I was getting "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
    
    0 讨论(0)
  • 2020-12-13 00:01

    Have you checked if your nginx binary really exists? please check if

    #whereis nginx
    

    outputs the binary path and check this path with your init script from /etc/init.d/nginx. e.g.

    DAEMON=/usr/sbin/nginx
    

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

    0 讨论(0)
  • 2020-12-13 00:03

    In my case those network command's outputs showed nginx was correctly binding to port 80, yet the ports weren't externally accessible or visible with nmap.

    While I suspected a firewall, it turns out that old iptables rules on the machine were redirecting traffic from those ports and conflicting with nginx. Use sudo iptables-save to view all currently applicable rules.

    0 讨论(0)
  • 2020-12-13 00:05

    I ran into the same problem, I got a Failed to load resource: net::ERR_CONNECTION_REFUSED error when connecting over HTTP, but fine over HTTPS. Ran netstat -tulpn and saw nginx not binding to port 80 for IPv4. Done everything described here. Turned out to be something very stupid:

    Make sure the sites-available file with the default_server is actually enabled.

    Hope this saved some other poor idiot out there some time.

    0 讨论(0)
  • 2020-12-13 00:05

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

    1... Make sure nginx is running.

    ps aux | grep nginx
    

    2... Check for processes already bound to the port in question.

    lsof -n -i:80
    

    3... Make sure nginx has been reloaded.

    sudo nginx -t
    sudo nginx -s reload
    

    On Mac, brew services restart nginx is not sufficient to reload nginx.

    4... Try creating simple responses manually to make sure your location path isn't messed up. This is especially helpful when problems arise while using proxy_pass to forward requests to other running apps.

    location / {
        add_header Content-Type text/html;
        return 200 'Here I am!';
    }
    
    0 讨论(0)
  • 2020-12-13 00:09

    A semi-colon ; missing in /etc/nginx/nginx.conf for exemple on the line before include /etc/nginx/servers-enabled/*; can just bypass this intruction and nginx -t check will be successful anyway.

    So just check that all instructions in /etc/nginx/nginx.conf are ended with a semi-colon ;.

    0 讨论(0)
提交回复
热议问题