Connecting Your Domain to Web Hosting

7 min read

## The Link Between Domains and Hosting Registering a domain and purchasing web hosting are two separate activities that you connect through DNS (Domain Name System). Your domain is essentially a name registered in a global database. Your Web Hosting is a server somewhere that stores your website files. DNS (Domain Name System) is the system that maps your domain name to that server's IP address. This guide explains every method for connecting a domain to hosting, from the simplest (changing nameservers) to the most granular (managing individual A records). ## Method 1: Change Nameservers (Simplest) The most common approach when your domain and hosting are with different providers: point your domain's nameservers to your hosting provider. This delegates all DNS (Domain Name System) management to the host. ### What Are Nameservers? Nameservers are the authoritative DNS (Domain Name System) servers for your domain. When anyone looks up `yourdomain.com`, the global DNS system ultimately queries whichever nameservers are registered for your domain. Whoever controls those nameservers controls all DNS records — your website, email, and everything else. By default, your Domain Registrar controls your nameservers. When you switch to your host's nameservers, the host's DNS (Domain Name System) servers become authoritative for your domain. ### Finding Your Host's Nameservers Your hosting provider lists their nameservers in their welcome email or documentation. Common examples: | Host | Nameservers | |---|---| | Bluehost | ns1.bluehost.com, ns2.bluehost.com | | SiteGround | ns1.siteground.net, ns2.siteground.net | | GoDaddy | ns1.domaincontrol.com, ns2.domaincontrol.com | | Namecheap | dns1.namecheaphosting.com, dns2.namecheaphosting.com | ### Changing Nameservers at Your Registrar 1. Log into your Domain Registrar's control panel 2. Find "Nameservers" or "DNS" settings for your domain 3. Switch from the default (registrar's) nameservers to your host's nameservers 4. Enter both nameserver hostnames provided by your host 5. Save the changes DNS Propagation after changing nameservers typically takes **24–48 hours** globally, though most resolvers update within 2–4 hours. During this window, some visitors see the old server, some see the new one. **Advantage**: Simple. Your host manages all DNS settings. **Disadvantage**: You lose direct control of individual DNS records at your registrar. Any DNS changes require logging into your host's panel. ## Method 2: Add an A Record (More Control) If you want to keep your Domain Registrar's nameservers (which is common when your registrar also manages email or other DNS records), you can point just the web traffic to your host by adding an A Record. An A Record maps a hostname to an IPv4 address: ``` Type Host Value TTL A @ 203.0.113.1 3600 A www 203.0.113.1 3600 ``` The `@` represents your root domain (`yourdomain.com`). The second record covers `www.yourdomain.com`. Your host provides the IP address (203.0.113.1 is an example — use the actual IP your host gives you). ### Finding Your Host's IP Address Log into your hosting control panel (cPanel, Plesk, or your VPS dashboard) and look for: - **cPanel**: "Server Information" or the welcome email - **VPS/Cloud**: The Droplet/Instance IP address in your cloud provider's console - **Managed hosting**: Your host's support documentation or welcome email Some hosts use multiple IPs for load balancing. They'll specify exactly which IP(s) to use. ### When to Add a www CNAME Instead Many hosts recommend pointing `www` to a CNAME Record rather than a duplicate A Record: ``` Type Host Value TTL A @ 203.0.113.1 3600 CNAME www yourdomain.com 3600 ``` The CNAME Record for `www` points to your root domain. This means if your IP ever changes, you only update one A Record rather than two. However, some DNS providers don't support CNAMEs at the root (`@`) level — this is the "CNAME flattening" issue. Always use an A Record for the root domain and optionally a CNAME for `www`. ## Method 3: Use Cloudflare as Intermediary (Recommended for Most) Cloudflare offers a free plan that sits between your Domain Registrar and your hosting server. This gives you: - Cloudflare's global CDN for faster load times - DDoS protection - Free SSL certificates - Easy DNS management with a clean interface - The ability to change hosting providers without users noticing (just update Cloudflare DNS) ### Setting Up Cloudflare 1. Sign up at cloudflare.com and add your domain 2. Cloudflare scans your existing DNS records and imports them 3. Change your Domain Registrar's nameservers to Cloudflare's (e.g., `nova.ns.cloudflare.com`, `rita.ns.cloudflare.com`) 4. In Cloudflare's dashboard, verify the A Record for your domain points to your host's IP 5. Enable the orange cloud icon (Cloudflare proxy) for the A record to activate CDN and SSL With Cloudflare proxy enabled, your origin server's real IP is hidden from visitors. Cloudflare's IPs appear in DNS instead. This has security benefits (prevents direct attacks to your server's IP) and performance benefits (content cached at Cloudflare's edge nodes). ## Configuring Specific Scenarios ### Static Sites on GitHub Pages / Netlify / Vercel These platforms use CNAME records rather than A records: **GitHub Pages:** ``` Type Host Value TTL CNAME www username.github.io 3600 A @ 185.199.108.153 3600 A @ 185.199.109.153 3600 A @ 185.199.110.153 3600 A @ 185.199.111.153 3600 ``` GitHub requires all four A records for the root domain and a CNAME for `www`. **Netlify:** ``` Type Host Value TTL CNAME www yoursite.netlify.app 3600 A @ 75.2.60.5 3600 ``` Or change your nameservers entirely to Netlify DNS for full management through their dashboard. **Vercel:** ``` Type Host Value TTL CNAME www cname.vercel-dns.com 3600 A @ 76.76.21.21 3600 ``` ### Shared Hosting via cPanel When your host provides a cPanel account, they give you: 1. A primary IP address for your account 2. Nameservers for their shared hosting cluster Use either Method 1 (change nameservers) or Method 2 (add A records) depending on whether you want the host to manage all DNS or just web traffic. ### VPS / Cloud Server With a VPS (DigitalOcean, Linode, Vultr, AWS EC2), you control the server and know its public IP address directly. Use Method 2 (A record) and point it to your VPS's public IP. ## Setting Up Email Alongside Web Hosting One of the most common questions: "If I point my nameservers to my web host, what happens to my email?" When you change nameservers, ALL DNS records move to the new nameservers. Your email will break unless you recreate MX records, SPF Record, DKIM, and DMARC records on the new DNS provider. **Before changing nameservers:** 1. Write down all existing DNS records (especially MX and email authentication records) 2. Set up those records on the new DNS provider 3. Only then change the nameservers Most hosts support adding MX records for external email providers like Google Workspace. In cPanel, you can add custom MX records in the "Email Routing" or "Zone Editor" section. **Alternative**: Keep your Domain Registrar's nameservers and use Method 2 (individual A records) for web hosting. Your email DNS records stay exactly where they are and are unaffected. ## DNS Propagation and TTL During Cutover When switching web hosting, plan for DNS Propagation delays: 1. **Lower TTL first**: Set TTL (Time To Live) on your A record to 300 seconds (5 minutes) 24–48 hours before the switch 2. **Make the change**: Update the A record to your new host's IP 3. **Propagation**: Within 5–15 minutes, most resolvers pick up the new IP (thanks to the low TTL) 4. **Raise TTL after**: Once the transition is confirmed working, raise TTL (Time To Live) back to 3600 With a high TTL (like 86400 = 24 hours), some visitors continue reaching your old host for up to 24 hours after the switch. Low TTL + advance preparation minimizes this window. ## SSL / HTTPS After Domain Connection Once your domain points to hosting, configure SSL: - **Shared hosting (cPanel)**: Use Let's Encrypt via "SSL/TLS" in cPanel → "Let's Encrypt SSL" - **Cloudflare proxy**: Enable "Full (strict)" SSL mode — Cloudflare handles the visitor-facing certificate - **VPS**: Install Certbot and configure Let's Encrypt directly on your server - **Netlify/Vercel/GitHub Pages**: SSL is automatic when you add a custom domain Without SSL, browsers show security warnings and Google penalizes your search rankings. ## Verifying the Connection After making DNS changes: 1. **Check propagation**: Use DNS Record Helper to see if your A Record has propagated globally 2. **Visit your domain**: Open a browser and navigate to your domain 3. **Check SSL**: Confirm the padlock appears and HTTPS works 4. **Test www and root**: Both `yourdomain.com` and `www.yourdomain.com` should resolve correctly Use the WHOIS Lookup Tool to confirm your nameservers have updated to the expected values if you changed them. ## Next Steps - **Domain and Hosting: Buy Together or Separately?** — Should you buy domain and hosting from the same provider? - **Custom Email with Your Domain: Complete Setup Guide** — Set up email alongside your new web hosting - **MX Records Deep Dive: Email Routing Explained** — Understand how email routing DNS works - **Troubleshooting Email Delivery Issues** — Debug DNS issues affecting email after host migration

Related Guides