How to Connect a Domain Name to AWS EC2: Complete 2026 Guide
By Braincuber Team
Published on March 18, 2026
Connecting a domain name to a website hosted on AWS EC2 doesn't have to be complicated. Whether you purchased your domain from Namecheap, GoDaddy, or other providers, this comprehensive guide will walk you through the entire process with practical steps and clear instructions.
What You'll Learn:
- Set up and configure AWS EC2 instances for web hosting
- Install and configure NGINX web server on Ubuntu
- Create and manage Route 53 hosted zones for DNS
- Configure A records and aliases for domain routing
- Update nameservers with domain providers like Namecheap
- Understand DNS propagation and troubleshooting
The 4-Step Process Overview
The domain connection process involves four major steps that, when followed correctly, will seamlessly connect your custom domain to your AWS EC2-hosted website.
Set Up Your Website on EC2
Launch an EC2 instance, connect to it, and install NGINX web server for hosting your website.
Set Up Route 53 for DNS Management
Create a hosted zone in Route 53 and configure DNS records to point your domain to the EC2 instance.
Update Nameservers with Domain Provider
Replace your domain provider's default nameservers with the ones provided by Route 53.
Wait for DNS Propagation
Allow time for DNS changes to propagate across the internet and verify your domain is working.
Step 1: Setting Up Your Website on EC2
Begin by launching an AWS EC2 instance and installing a web server to host your website. We'll use Ubuntu with NGINX for this example.
Launch EC2 Instance
Navigate to AWS Management Console, search for EC2, and click Launch Instance. Choose Ubuntu Server 22.04 LTS (Free tier eligible) and t2.micro instance type.
Configure Security Group
Create a security group allowing SSH, HTTP, and HTTPS traffic. Set the source to Anywhere (0.0.0.0/0) for web access.
Create SSH Key Pair
Generate a new RSA key pair with .pem format for secure connection to your instance. Download and store the private key securely.
Connecting to Your EC2 Instance
Use EC2 Instance Connect
Select your instance and click Connect. Choose EC2 Instance Connect to open a terminal directly in your browser.
Update Package List
Run sudo apt update to refresh the package list on your Ubuntu instance before installing new software.
sudo apt update
Installing NGINX Web Server
Install NGINX
Run sudo apt install nginx -y to install the NGINX web server on your Ubuntu instance.
Verify Installation
Access your instance's public IP address in a browser to see the default NGINX welcome page.
sudo apt install nginx -y
Step 2: Setting Up Route 53 for DNS Management
AWS Route 53 provides DNS management services that will help you connect your domain name to your EC2 instance. Create a hosted zone and configure DNS records.
Access Route 53
Navigate to Route 53 in the AWS Management Console and click Get started to begin DNS configuration.
Create Hosted Zone
Enter your domain name, provide a description, and select Public hosted zone to make your website accessible to everyone.
Adding DNS Records
Create A Record
Add an A record with your EC2 instance's public IP address. Leave the subdomain field empty for the root domain.
Add WWW Alias Record
Create a record for www subdomain with Alias enabled, pointing to your root domain A record.
| Record Type | Name | Value | Purpose |
|---|---|---|---|
| A Record | @ (root) | EC2 Public IP | Points domain to EC2 |
| A Record | www | Alias to @ | Handles www subdomain |
| NS Record | @ (root) | Route 53 NS | Nameservers for domain |
Step 3: Updating Nameservers with Domain Provider
Replace your domain provider's default nameservers with the ones provided by Route 53 to complete the DNS configuration.
Copy Route 53 Nameservers
From your Route 53 hosted zone, copy the four NS (Name Server) records provided by AWS.
Log into Domain Provider
Access your domain provider's dashboard (Namecheap, GoDaddy, etc.) and navigate to domain management.
Update Nameservers
Select Custom DNS, remove existing nameservers, and add the four Route 53 nameservers. Save the changes.
Namecheap Example
In Namecheap, click Domain list → Manage → Nameservers → Custom DNS. Add all four nameservers and click the checkmark to save changes.
Step 4: DNS Propagation and Verification
After updating nameservers, you need to wait for DNS propagation to complete before your domain becomes active.
Wait for Propagation
DNS propagation can take anywhere from a few minutes to over 24 hours. Be patient during this process.
Test Your Domain
Enter your domain name in a browser to verify it displays your NGINX welcome page or website content.
DNS Propagation Time
Typically takes 5-30 minutes, but can take up to 24 hours depending on your domain provider and TTL settings.
Next Steps
Consider installing an SSL certificate to enable HTTPS and improve security for your website visitors.
Frequently Asked Questions
How long does DNS propagation take?
DNS propagation typically takes 5-30 minutes but can take up to 24 hours depending on your domain provider and TTL (Time To Live) settings.
What if my domain isn't working after 24 hours?
Check that you've correctly updated all nameservers, verify your DNS records in Route 53, and ensure your security group allows HTTP/HTTPS traffic.
Do I need to install SSL?
While not required for domain connection, SSL is highly recommended for security and better user experience. You can use Let's Encrypt for free SSL certificates.
Can I use a different web server instead of NGINX?
Yes, you can use Apache or other web servers. The domain connection process remains the same - only the web server installation differs.
Ready to Launch Your Website?
Now that you've connected your domain to AWS EC2, you're ready to deploy professional websites with custom domains. Take the next step and secure your site with SSL.
