ping: cannot resolve Unknown host

Posted August 21, 2021 651 views
NginxNode.jsDNSDigitalOcean Droplets

I deployed a nodejs application with nginx server.

when I open the browser to the server’s ip
I can see the app running

However, when I open it with my domain name
I get the following error

‘This site can’t be reached refused to connect.’

When I run the following command
I can see the app content

When I ping it
I get the following error

'ping: cannot resolve Unknown host’

Any idea what could be the issue?

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
1 answer

Hi there @ahmadmjh,

You can not ping over HTTP as ping uses ICMP rather than HTTP.

To avoid that error, you have to remove the http:// part of the FQDN as follows:


I’ve tested it and it seems to be working as expected.

Hope that this helps!

  • ping now is working fine.

    However, I’m still not able to access the domain by the browser.

    When I open it, I get the following error

    This site can’t be reached refused to connect.
    • Hello,

      It is possible that your Nginx server blocks have different content for your domain name and your default Nginx server block. That could explain why you see the correct content when visiting the IP but not when visiting the domain name.

      Can you share the two Nginx server blocks that you have at /etc/nginx/sites-enabled directory?


      • I can see that I have only one server bloc enabled

        server {
            listen 80 default_server;
            listen [::]:80 default_server;
            root /var/www/html;
            location / {
                proxy_pass http://localhost:3000;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection 'upgrade';
                        proxy_set_header Host $host;
                        proxy_cache_bypass $http_upgrade;
        # Virtual Host configuration for
        #server {
        #   listen 80;
        #   listen [::]:80;
        #   server_name;
        #   root /var/www/;
        #   index index.html;
        #   location / {
        #       try_files $uri $uri/ =404;
        #   }
        • Hello,

          I would recommend removing the http:// and the trailing slash / from the IP address under your server name list.

          I believe that if you run an Nginx config test you would get a warning that the server name has suspicious symbols in it.

          You can run an Nginx config test with the following command:

          sudo nginx -t

          If you then get Syntax Ok, you would need to restart Nginx with:

          sudo systemctl restart nginx

          Let me know how it goes.