Question

How to correctly set DNS entries to Namecheap as subdomain

This is the part I’m currently at: https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04#step-5-setting-up-server-blocks-recommended Thing is, it’s really confusing to set up the correct DNS, since it takes 24 hours to check if they’re right. What I want is to have a server block that is connected with a subdomain in Namecheap. In my Networking panel in DO I set up a domain website.com and the DNS entry is Type A, hostname sub.website.com and value 165.69.24.420 Now in Namecheap the same: A Record, sub.website.com and value 165.69.24.420.

Am I missing something? When I whip up the website it says DNS_PROBE_FINISHED_NXDOMAIN, even after 24 hours. I saw that I had to put in

-   ns1.digitalocean.com
-   ns2.digitalocean.com
-   ns3.digitalocean.com

Into Namecheap, but that would be for the root domain, right? It does confus me alot and I hope to find a solution. The root domain for website.com points to another server.


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.

Bobby Iliev
Site Moderator
Site Moderator badge
March 10, 2024
Accepted Answer

Hey!

To correctly set up a subdomain with DNS entries in Namecheap and point it to a server managed by DigitalOcean, you need to understand the roles of different DNS records and where they should be configured. Since your root domain (website.com) is hosted elsewhere and you want only the subdomain (sub.website.com) to point to the DigitalOcean server, you’ll need to set up specific DNS records carefully.

  1. Since you’re not moving your main domain to DigitalOcean, you don’t need to change your domain’s nameservers to DigitalOcean’s (ns1.digitalocean.com, ns2.digitalocean.com, ns3.digitalocean.com). You only need to create a DNS record for the subdomain within DigitalOcean’s networking panel:

    • Record Type: A
    • Hostname: sub.website.com (or just sub if DigitalOcean autofills the domain part)
    • Value (points to): 165.69.24.420 (your server’s IP address)
  2. In your Namecheap DNS settings for website.com, you need to add a record that points sub.website.com to your DigitalOcean server:

    • Record Type: A
    • Host: sub (just the subdomain part, without the main domain)
    • Value: 165.69.24.420 (your DigitalOcean server’s IP address)

    This setup tells the DNS system that when someone requests sub.website.com, they should be directed to your DigitalOcean server.

  3. DNS changes can take some time to propagate, typically up to 24 hours, but often it’s much quicker. You can check the status of your DNS propagation using tools like https://www.whatsmydns.net/.

  4. If, after the propagation period, sub.website.com still isn’t resolving to your server, double-check the following:

    • Ensure there are no conflicting records in Namecheap (like another A record or CNAME for sub).
    • Verify the IP address is correctly entered and corresponds to your DigitalOcean server.
    • Check if the DigitalOcean side settings are correct and if the domain is properly added to the networking panel.
  5. Make sure your server is configured to respond to requests for sub.website.com. If you’re using Nginx, this involves setting up a server block for sub.website.com. If you’re using another web server, the configuration would be similar in context.

Let me know how it goes!

Best,

Bobby

KFSys
Site Moderator
Site Moderator badge
March 9, 2024

Heya @eriksachse,

So, the Nameservers show from where your DNS is being controlled by however the subdomain DNS would be controlled by where your root domain’s DNS is.

Basically, there is no need to create your subdomain in DigitalOcean as a domain. What you need to do is add an A record for your subdomain where website.com’s DNS is being controlled by. If it’s Namecheap, then that is the place where you should add the DNS for your subdomain.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel