Question

This site can’t be reached refused to connect.

I’m trying to get nginx to work on my server. I was trying to get it to work with a more complex config, but I gave up and reinstalled it. I’m working with a really simple config here:

**File: /etc/nginx/nginx.conf **

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

**File: /etc/nginx/sites-enabled/default **

server { listen 80 default_server; listen [::]:80 default_server;

    root /var/www/html;

    index index.html index.nginx-debian.html;

    server_name [mydomain] [www.mydomain];

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }

}

I followed the instructions on: https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04

I still get a This site can’t be reached [my IP] refused to connect.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I facing same problem. I tried this but wont work

Have you tried server_name 127.0.0.1; where 127.0.0.1 works for localhost but you can change it for the real server’s IP?