How to map domain to Amazon EC2 instance without using Route 53

As you know Amazon’s Route 53 isn’t free and it costs you money to even map your domain to your server. And it is also a little complex than the usual domain mapping process, i.e. you have to change the DNS of your domain.

In this guide I am going to show you how to map your domain to your Amazon EC2 without using Route 53 in a very simple way.

Step 1:

Get the public ip address of your EC2 instance.

If you don’t know your instance’s public ip address then open your aws console, go to EC2 Dashboard, then click on ‘Running instance’, then you will see a list of all the instances you have. Scroll horizontally untill you see ‘IPv4 Public IP’ section, the value at that section will be your public ip address.

Step 2:

Open your Domain Registrar’s site and go to DNS Management then to Manage Zones. If you can’t find it then a quick google search of “how to add A record in {your domain registrar name here}” will get you there.

There you will see a list of Records, namely ‘A’, ‘CNAME’, ‘NS’, ‘MX’, etc. We don’t have to touch those existing records, we will create new record for our server.

There will be an option to add new record. We have to add new ‘A’ record, so if there is explicitly mentioned ‘ADD A Record’, then click on that.

Then a form will open up, like below:


Note: If you have enabled the IPv6 then you have to use that one. Follow the process below but instead of ‘A’ record you have to add new ‘AAAA’ record.

If there is a dropdown for Type, then select ‘A’ from that list. Insert ‘@’ (without quotes) at the ‘Host’ input field and your server’s ip address at the ‘Points to’ input field. If the ‘TTL’ value is set already then don’t change it, if it is not set then set it to 1 Hour. Now save it.


Now, we have to add another ‘A’ record. Open up new form. This time in ‘Host’ field insert ‘*’ (without quotes) and in the ‘Points to’ field your ip address as before. This will allow you to map your sub-domain to your server i.e., your domain with ‘www’.


Step 3:

Set the domain name in your Nginx or Apache configuration file, as server name.

For Nginx it is:


And for Apache it is:


Note: if you have created new server files (i.e. virtual hosts) for your set up then add domain there.

Don’t forget to map both www and non-www variant of the domain.

Restart your server. And you are done!