Nginx – Configuration Error – Connection Refused

By setting up nginx it can happen that then it is not possible to connect to the server and that one recoils an error of the type hostname not found

In the terminal, we start by using

curl -v domain.dev

Error appears

 Rebuilt URL to: domain.dev/
Hostname was NOT found in DNS cache
Trying 127.0.0.1...
connect to 127.0.0.1 port 80 failed: Connection refused
Failed to connect to domain.dev port 80: Connection refused
Closing connection 0
curl: (7) Failed to connect to domain.dev port 80: Connection refused

We can try to restart nginx

sudo service nginx restart

in the event of a failure

nginx -t

correct the error found, it should be explicit.

then controller if nginx listen well on port 80

sudo netstat -tulpn grep 80
tcp 0 0.0.0.0:80 0.0.0.0:LISTEN 20621/nginx     
tcp6 0 0 :::80 :::* LISTEN 20621/nginx 
Publicités

if not, check that links are well done from site-enabled to site-available

to do it automatically

    for host in /etc/nginx/sites-available/ Do
        sudo ln -sf $-host
    Done
Publicités

Leave a Reply