Cannot resolve non-www domain however www-domain works perfectly fine

I have a digitalocean droplet setup with the LAMP droplet and have set this up to the URL - it loads fine if I include the ‘www’ in the URL but if I remove the ‘www’ it never loads.

Here is my virtual hosts entry in the conf file

<VirtualHost *:80>
    DocumentRoot /var/www/gavkcouk/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <IfModule mod_dir.c>
        DirectoryIndex index.php index.cgi index.html index.xhtml >

When I ping from the terminal I get the error ping: cannot resolve Unknown host (but works fine if I ping

Below is the DNS and A records that I have setup in the digitalocean control panel (see the image link below) so I have the 3 nameserver entries and then the 2 A records (I have added two as I want to setup certbot and it recommends adding 2 A records one www and one non-www)

Image link of my A records

Can anyone suggest what I am doing wrong - I just want both & to resolve so they show the exact same webpage.

Thanks in advance

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello @zabs

Looks like the issue is resolved or you were experiencing some temporary issue. The ping and curl to your domain work fine for me. You can clear the cache and check the functionality.

ping -c 4
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=55 time=193.036 ms
64 bytes from icmp_seq=1 ttl=55 time=157.177 ms
64 bytes from icmp_seq=2 ttl=55 time=156.103 ms
64 bytes from icmp_seq=3 ttl=55 time=158.923 ms

--- ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 156.103/166.310/193.036/15.463 ms
curl -I
HTTP/1.1 200 OK
Date: Wed, 28 Oct 2020 18:23:21 GMT
Server: Apache/2.4.41 (Ubuntu)
Last-Modified: Tue, 27 Oct 2020 16:07:28 GMT
ETag: "9d-5b2a93e58384d"
Accept-Ranges: bytes
Content-Length: 157
Vary: Accept-Encoding
Content-Type: text/html