Question

ping: cannot resolve http://haltamah.app: Unknown host

Posted August 21, 2021 134 views
NginxNode.jsDNSDigitalOcean Droplets

Hello..
I deployed a nodejs application with nginx server.

when I open the browser to the server’s ip http://159.89.55.168
I can see the app running

However, when I open it with my domain name http://haltamah.app
I get the following error

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

When I run the following command
curl http://haltamah.app
I can see the app content

When I ping it
ping http://haltamah.app
I get the following error

'ping: cannot resolve http://haltamah.app: 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:

ping haltamah.app

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

Hope that this helps!
Regards,
Bobby

  • 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
    haltamah.app 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?

      Regards,
      Bobby

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

        server {
            listen 80 default_server;
            listen [::]:80 default_server;
        
            root /var/www/html;
        
            server_name http://159.89.55.168/ www.haltamah.app haltamah.app;
        
            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 example.com
        #server {
        #   listen 80;
        #   listen [::]:80;
        #
        #   server_name example.com;
        #
        #   root /var/www/example.com;
        #   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.
          Regards,
          Bobby