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

Error appears

 Rebuilt URL to:
Hostname was NOT found in DNS cache
connect to port 80 failed: Connection refused
Failed to connect to port 80: Connection refused
Closing connection 0
curl: (7) Failed to connect to 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 20621/nginx     
tcp6 0 0 :::80 :::* LISTEN 20621/nginx 

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

Leave a Reply