This site can’t be reached refused to connect.

Posted October 15, 2017 10.1k views
NginxUbuntu 16.04

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/;

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 defaultserver;
listen [::]:80 default

    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:

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

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.

Submit an Answer
2 answers

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

I facing same problem. I tried this but wont work