How to add WWW CNAME on DigitalOcean

If you host website on DigitalOcean including a domain name and you haven’t configured it properly, there may be some issue as the example here. Your website is working properly, but you can’t access it if it begins with www (http://example.com is working fine, but not http://www.example.com). You can’t even ping to your www domain (www.example.com).
Server not found on Firefox

Solution

In this case, the issue is that you haven’t configure the CNAME record properly on DigitalOcean. A CNAME record is used to specify that a domain name is an alias for another domain, the “canonical” domain.

To fix the issue, you have to add www CNAME record on DigitalOcean.

Step-by-step

Note: The domain name and IP address on this article are example only.

  1. Login to your control panel on DigitalOcean and click DNS.
    Control Panel on DigitalOcean
  2. On DNS, click on View (the magnifier icon) next to the domain that you want.
    Configure DNS on DigitalOcean
  3. On the selected domain, check if there is already a www CNAME record. If not, click Add Record. Otherwise, your issue may not be this case.
    Add Record on DigitalOcean
  4. Click CNAME button under Select Record Type section.
    Add CNAME Record on DigitalOcean
  5. Type www on the left textbox and your domain on the right textbox. And click Create.
    Note: The domain name must ends with dot (.)
    Add CNAME Record on DigitalOcean
  6. Now you will see a www CNAME record point to your domain name.
    Server not found on Firefox
  7. It may takes few seconds or minutes for DNS record to propagate on the Internet. Then you can check with ping command and you can now access your website with www domain.
    Ping a WWW domain on Windows Command Prompt

Leave a Reply