How to Add a Domain Name to DigitalOcean | Code Boost
Description: Adding your domain name to DigitalOcean allows you to manage your DNS records directly from the DigitalOcean Control Panel. This simplifies the process of configuring your servers...

Article

# How to Add a Domain Name to DigitalOcean

By Matt · Dec 1, 2024

Adding your domain name to DigitalOcean allows you to manage your DNS records directly from the DigitalOcean Control Panel. This simplifies the process of configuring your servers and applications. In this guide, we'll walk you through the steps to add your domain name to DigitalOcean and set up the necessary DNS records.

### Prerequisites to Adding a Domain to a DigitalOcean account

# Click here for free DigitalOcean credit

- A Registered Domain Name: You should have purchased a domain from a domain registrar (e.g., GoDaddy, Namecheap).
- DigitalOcean Account: Access to your DigitalOcean account where you'll manage your Droplets and networking settings.
- Access to Domain Registrar Account: You'll need to update your domain's nameserver settings.

### Step-by-Step Guide

#### Step 1: Log in to DigitalOcean Control Panel

- Navigate to the DigitalOcean Control Panel and sign in with your credentials.

#### Step 2: Access the Networking Section

- From the main dashboard, click on the Networking option in the left-hand menu.

#### Step 3: Add Your Domain

1. In the Networking section, ensure you're on the Domains tab.
2. Click the Add Domain button.
3. In the Enter domain field, type your domain name (e.g., example.com).
4. Optionally, you can select a Droplet to assign to this domain immediately. This will create an A record pointing to the Droplet's IP.
5. Click Add Domain to proceed.

#### Step 4: Update Your Domain's Nameservers

To allow DigitalOcean to manage your DNS records, you need to point your domain's nameservers to DigitalOcean.

1. Log in to your domain registrar's account (where you bought your domain).
2. Find the DNS management or nameserver settings for your domain.
3. Replace the existing nameservers with DigitalOcean's nameservers:
4. Copy code
5. ns1.digitalocean.com
6. ns2.digitalocean.com
7. ns3.digitalocean.com
8. Save the changes.

Note: DNS changes can take up to 48 hours to propagate globally, but they often update within a few hours.

#### Step 5: Add DNS Records in DigitalOcean

Now that your domain is added, you can configure DNS records.

- A Record: Points the domain to an IP address.
  - Click Add Record and select A.
  - Leave the Hostname field blank or enter @ to represent the root domain.
  - Enter your Droplet's IP address in the Will Direct To field.
  - Click Create Record.
- CNAME Record: Points a subdomain to another domain.
  - For the www subdomain:
    - Click Add Record and select CNAME.
    - In Hostname, enter www.
    - In Alias To, enter @ or your domain name.
    - Click Create Record.
- MX Record: Directs incoming email to a mail server.
  - If you use email services, add MX records as specified by your email provider.

#### Step 6: Verify Your DNS Settings

- Use a tool like DNS Checker to verify that your DNS records are correctly propagating.
- Check that your domain resolves to your Droplet's IP address by running:
- bash
- Copy code
- ping yourdomain.com
- Replace yourdomain.com with your actual domain.

### Troubleshooting Tips

- Delayed Propagation: If changes aren't appearing, it might be due to DNS propagation delays.
- Incorrect Nameservers: Ensure you've correctly set DigitalOcean's nameservers at your registrar.
- Typographical Errors: Double-check all entries for typos.

### Conclusion

By adding your domain name to DigitalOcean, you've centralized your DNS management, making it easier to configure and manage your applications. This setup is essential for hosting websites, setting up email, and other domain-related tasks.

### Next Steps

- Set Up SSL Certificates: Secure your website with HTTPS by installing SSL certificates.
- Configure Hosting Environment: Set up web servers like Nginx or Apache to serve your website.
- Create Subdomains: Add subdomains for different services (e.g., blog.example.com).

# Click here for free DigitalOcean credit