How to Point a Domain to AWS EC2 (Step-by-Step Guide)

After launching an AWS EC2 instance, the next critical step is connecting your domain name so users can access your website easily.
Instead of using a public IP address like 3.110.xxx.xxx, you can map your domain (e.g., yoursite.com) to your EC2 server. This process is called pointing a domain to AWS EC2.
In this complete guide, you will learn everything step-by-step, including DNS setup, Route 53, SSL setup, and common mistakes to avoid.
What Does “Pointing a Domain” Mean?
Pointing a domain means connecting your domain name to a server’s IP address using DNS (Domain Name System).
When a user enters your domain in a browser:
- DNS converts domain → IP address
- Browser connects to your EC2 server
- Your website loads
Prerequisites
Before you start, make sure you have:
- A running AWS EC2 instance
- Public IPv4 address of your instance
- A domain name (from any registrar)
- Access to DNS settings of your domain
Step 1: Get Your EC2 Public IP Address
- Login to AWS Console
- Go to EC2 Dashboard
- Click on “Instances”
- Select your instance
- Copy the Public IPv4 address
👉 Example: 13.233.xxx.xxx
Step 2: Open Your Domain DNS Settings
Login to your domain provider (GoDaddy, Namecheap, etc.) and open DNS management.
Look for:
- DNS Management
- Zone Editor
- Manage DNS
Step 3: Add A Record (Most Important Step)
Add a new DNS record:
- Type: A
- Host/Name: @
- Value: Your EC2 Public IP
- TTL: Default (300 or Auto)
👉 This connects your root domain (example.com) to EC2.
Step 4: Add WWW Record (Optional but Recommended)
To make www.yoursite.com work:
Option 1 (A Record):
- Type: A
- Host: www
- Value: same EC2 IP
Option 2 (CNAME):
- Type: CNAME
- Host: www
- Value: yourdomain.com
Step 5: Save and Wait for DNS Propagation
DNS changes take time to update globally.
- Minimum: 5–10 minutes
- Maximum: 24 hours
You can check using tools like “DNS Checker”.
Step 6: Test Your Domain
Open your browser and enter:
If everything is correct, your EC2-hosted website will load.
Important: Use Elastic IP (Highly Recommended)
By default, EC2 public IP changes when you restart the instance.
Solution: Allocate Elastic IP
Steps:
- Go to EC2 → Elastic IPs
- Allocate new IP
- Associate with your instance
👉 Now your IP is permanent.
Using AWS Route 53 (Advanced Method)
Instead of using your domain provider’s DNS, you can use AWS Route 53.
Steps:
- Go to Route 53
- Create Hosted Zone
- Add your domain name
- Copy nameservers
- Update nameservers in your domain registrar
- Add A record pointing to EC2
Benefits:
- Better performance
- Easy AWS integration
- Advanced routing features
Setting Up HTTPS (SSL Certificate)
After pointing domain, secure it with HTTPS.
Option 1: Use Let’s Encrypt (Free)
On EC2 (Ubuntu):
sudo apt update
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx
Option 2: Use AWS Load Balancer + ACM
For production setups, use AWS Certificate Manager.
Security Group Configuration (Very Important)
If your site is not opening, check EC2 security group.
Allow:
- Port 80 (HTTP)
- Port 443 (HTTPS)
Steps:
- Go to EC2 → Security Groups
- Edit inbound rules
- Add HTTP and HTTPS
Common Problems and Solutions
1. Domain Not Working
- Wait for DNS propagation
- Check A record IP
2. Website Not Loading
- Check web server (Apache/Nginx)
- Check firewall
3. IP Changed Suddenly
- Use Elastic IP
4. HTTPS Not Working
- Install SSL certificate
Real-World Example
Let’s say:
- Domain: myblog.com
- EC2 IP: 13.233.xxx.xxx
DNS setup:
- A Record → @ → 13.233.xxx.xxx
- A Record → www → 13.233.xxx.xxx
Now both:
- myblog.com
- www.myblog.com
will open your EC2 website.
Best Practices
- Always use Elastic IP
- Enable HTTPS
- Use Cloudflare or CDN for speed
- Monitor server uptime
FAQs
How long does DNS take?
5 minutes to 24 hours.
Can I point multiple domains?
Yes, using multiple A records.
What if EC2 stops?
Website will go offline.
Can I use subdomains?
Yes (blog.domain.com → A record)
Final Thoughts
Pointing a domain to AWS EC2 is a simple but essential step in deploying your website. Once you understand DNS and follow the correct steps, you can easily connect your domain to your server.
With proper setup like Elastic IP, SSL, and security rules, your site will be stable, secure, and production-ready.
Conclusion
You now know how to point a domain to AWS EC2 step-by-step. Follow this guide carefully, and your website will be live with your domain in no time.
