EC2 instance has no public DNS
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
In the world of Amazon Web Services (AWS), Elastic Compute Cloud (EC2) stands as one of its primary components, allowing users to run applications on virtual servers. When managing EC2 instances, users might encounter a peculiar situation where an instance doesn't have a public DNS. This article explores the potential reasons for such an occurrence, examines the technical aspects, and provides insight into addressing the issue.
Understanding Public DNS
Before delving into the reasons why an EC2 instance might not have a public DNS, it's essential to understand what a Public DNS is. Public DNS is a domain name system address assigned to an instance to enable users to access it over the internet. It converts the public IP address of an instance to a readable domain-like name, which simplifies referencing by users and scripts.
Reasons an EC2 Instance Might Lack a Public DNS
Several conditions might prevent an EC2 instance from having a public DNS:
- Instance Does Not Have a Public IP:
When launching an instance in a Virtual Private Cloud (VPC) that does not have a public subnet, the instance won't be assigned a public IP, consequently lacking a public DNS. - VPC and Subnet Configuration:
If the default setting for the subnet does not automatically assign a public IP to the instances, it results in the absence of a public DNS. - Elastic IPs and DNS Resolution:
Instances that use Elastic IP addresses might not have public DNS names as AWS doesn't automatically create a public DNS for instances with Elastic IPs. - Security and Compliance:
Some architectural designs align with security and compliance policies which require instances to operate without direct internet exposure, foregoing a public DNS.
Technical Explanation
VPC and Subnet Configuration
When you create an EC2 instance, it's usually contained within a VPC. Each VPC can include multiple subnets which are classified as private or public. Public subnets are those with a route to the internet and will automatically assign public IP addresses to associated instances. However, this is controlled by certain configurations at the subnet level:
- In the AWS Management Console, each subnet has an attribute called "Auto-assign public IPv4 address." If this is set to "No," instances will not receive public IPs unless manually assigned. Consequently, no public DNS will be provided.
Elastic IP and DNS Resolution
Elastic IPs are static IPs designed for dynamic cloud computing, effectively maintaining a fixed IP address. However, AWS associates public DNS names with public IP addresses at the backend. Elastic IPs, being static, do not fall into that automatic association:
- Associating an Elastic IP doesn't automatically update with a public DNS.
Addressing the Issue
If an EC2 instance requires a public DNS for accessibility over the internet, there are several steps that can be taken:
- Enable Public IP at Launch: Ensure that the "Public IP" option during instance configuration is enabled.
- Modify Subnet Settings: Change the subnet's settings to automatically assign public IP addresses upon instance launch.
- Use Elastic IP with a Custom DNS: Assign an Elastic IP and manually map it to a custom domain name using third-party DNS management services.
- Reverse DNS Settings: Configure Reverse DNS records if Elastic IP addresses are used, which can facilitate email delivery and other services.
Summary Table
| Condition | Description | Result |
| Instance in Private Subnet | Instance launched in a non-public subnet. | No public IP or DNS. |
| Subnet Configuration | Auto-assign public IP disabled. | No public DNS. |
| Elastic IP Association | Elastic IP replaces dynamic public IP. | No automatic DNS resolution. |
| Security Policies | Compliance-driven constraints. | No public DNS for high security. |
Conclusion
While encountering an EC2 instance without a public DNS might appear problematic, understanding the inner workings of AWS networking resolves much of the confusion. By correctly configuring subnet attributes, leveraging Elastic IPs appropriately, and having clarity on AWS internet access practices, users can effectively manage their instances and ensure network accessibility.
Understanding these facets helps architect solutions that are secure, reliable, and aligned with business and operational needs. Whether for development, staging, or production environments, correctly assigning a public DNS when needed remains central to efficient AWS infrastructure utilization.
Related reading
- EC2 instance image on VirtualBOX?
- EC2 instance on Amazon and I am greeted with No space left on the disk
- EC2. Load balancer. At least two subnets must be specified
- EC2 Storage attached at sda is /dev/xvde1 cannot resize
- EC2/Route53 How Do I Point Apex Record at Load Balancer?
- Efficiently using a rate-limited API Echo Nest with distributed clients
- echo that outputs to stderr
- Eclipse cannot load SWT libraries

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.