EC2 instance has no public DNS


EC2 instance has no public DNS



A guy I work with gave me the EC2 credentials to log onto his EC2 console. I was not the one who set it up. Some of the instances show a public dns name and others have a blank public DNS. I want to be able to connect to the instances that have a blank public DNS. I have not been able to figure out why these show up as blank.





Are the instances inside a VPC? Check if there is a value next to the VPC ID field in the instance description screen.
– David Levesque
Jan 6 '14 at 5:16





I have the same problem. My instances are inside a VPC, and on the Subnet, I have checked the public DNS to be available. Still I'm getting no public DNS names. I can see that in my VPC configuration, it's saying DNS hostnames: no, but I cannot change that value and adding a new VPC doesn't give me the selection either.
– Wrench
Sep 20 '14 at 12:14


DNS hostnames: no





I have different problem when setup my-vpc, The DNS hostname: yes, but it is only Private ID when the instance is started. I can only get the Public IP when an Elastic IP is used.
– Chetabahana
Jul 18 '16 at 10:44



DNS hostname: yes





What helped me was a stop and start for the instance without the public IP/DNS (reboot didn't help). After instance was restarted, it got the public IP.
– justadev
Sep 20 '16 at 15:59




14 Answers
14



I had the same problem an solved it. Have a look at the step-by-step instructions:



Hope this helps!



Cheers





This is the best answer. It should be checked !
– Alberto Spelta
Feb 22 '15 at 16:04





The section containing VPCs is now called Networking. And to edit, you right-click on the VPC.
– nasch
May 20 '15 at 19:31





+1 you now also need to set your subnet to allow auto-assignment of public ip. Right click your subnet > modify auto-assign public ip > check the box
– Adam Hey
Aug 7 '15 at 5:56






@user1456508 this works flawlessly
– fiorentinoing
Sep 22 '15 at 13:05





Even when I tried to add an Elastic Ip, it was not working until that option to change dns hostnames was set to yes.
– RenatoSz
Jan 8 '16 at 15:01



There is a actually a setting in the VPC called "DNS Hostnames". You can modify the VPC in which the EC2 instance exists, and change this to "Yes". That should do the trick.



I ran into this issue yesterday and tried the above answer from Manny, which did not work. The VPC setting, however, did work for me.



Ultimately I added an EIP and I use that to connect.





Is there a way to do this without modifying the VPC as a whole? I want public DNS for one node in a VPC but don't want it to apply to every other node with an elastic IP in that VPC.
– Robbie Averill
Oct 30 '14 at 0:54





I think you should be able to add an elastic IP for just that node, no?
– Mike T
Oct 31 '14 at 12:59





Yeah, but it won't resolve internally without your suggestion in the answer :-)
– Robbie Averill
Oct 31 '14 at 17:49



Sounds like the instance was launched in VPC and while doing so, the check-box for Automatically assign a public IP address to your instances was not checked. Hence the instance does not have a public IP


Automatically assign a public IP address to your instances



You can assign an Elastic IP to this instance and then log in using that IP.





I tried connecting using the public ip with putty. but it said "server refused our key". I converted the .pem file to .ppk file using puttygen
– user1456508
Jan 6 '14 at 15:30





what user name are you using? which AMI is this ? what operating system is this ?
– slayedbylucifer
Jan 6 '14 at 16:57





Is there a way to assign a public IP after the fact? I don't see a way to edit the Instance details settings.
– David Balažic
Jan 27 '15 at 11:22





@slayedbylucifer What about a stopped instance?
– David Balažic
Jan 27 '15 at 16:17






@DavidBalažic, Same. for the lifecycle of an instance, you cannot attach pub IP. Pub IP can be attached only at the time of launch.
– slayedbylucifer
Jan 28 '15 at 6:33



At the end you will get your Public dns.





adding Public DNS to the VPC along with the assigned Elastic IP works. For some reason, the elastic IP can be pinged from the outside world through the Security Group but hitting a web app like Solr failed unless there's a public DNS assigned..
– false_memories
Jan 13 '16 at 16:10



This is the tip provided to resolve the issue which does not work:



Tip - If your instance doesn't have a public DNS name, open the VPC console, select the VPC, and check the Summary tab. If either DNS resolution or DNS hostnames is no, click Edit and change the value to yes.



Assuming you have done this and you are still not getting a Public IP then go over to the subnet in question in the VPC admin screen and you will probably discover "Auto-Assign Public IP" is not set to yes. Modify that setting then, and I know you don't want to here this, create a new instance in that subnet. As far as I can tell you cannot modify this on the host, I tried and tried, just terminate it.



In my case I found the answer from slayedbylucifer and others that point to the same are valid.
Even it is set that DNS hostname: yes, no Public IP is assigned on my-pvc (only Privat IP).


DNS hostname: yes



It is definitely that Auto assign Public IP has to be set Enable.
If it is not selected, then by default it sets to Use subnet setting (Disable)


Enable


Use subnet setting (Disable)



Assign Public IP





This is the correct answer. It should be selected.
– JonyD
Nov 29 '16 at 13:50



For me problem was in subnet settings.





This actually works
– David Gatti
Jun 22 '17 at 14:04



Just launch another instance (and also delete the one in question if it has no use) and make sure this time you check "Autoatically assign a public IP address to your instance". If not then as slayedbylucifer suggested; assign an Elastic IP (EIP) to the instance and then log in using that IP. Be careful though, if you are running the free AWS tier, an EIP will cost you money-- that's a whole 'nother topic..



First of all, there can be two reasons for this:



To solve this :



i) Go to AWS VPC console and select the VPC you have created.



ii) Then click on Actions and then enable DNS Resolution.


OR



Here you cannot change the setting; so create an ami image and then recreate the instance from that.



If the instance is in VPC, make sure both "DNS resolution" and "DNS hostnames" is set to "yes". You can do this in the Aws console UI. HTH!



Go to VPC console, select your VPC, and click ACTIONS menu, select Edit DNS Hostnames - select Yes. That should fix it.



For those using CloudFormation, the key properties are EnableDnsSupport and EnableDnsHostnames which should be set to true


VPC: {
Type: 'AWS::EC2::VPC',
Properties: {
CidrBlock: '10.0.0.0/16',
EnableDnsSupport: true,
EnableDnsHostnames: true,
InstanceTenancy: 'default',
Tags: [
{
Key: 'env',
Value: 'dev'
}]
}
}





Helpful answer, thanks. FYI the default for EnableDnsSupport is true so it's typically sufficient to indicate EnableDnsHostnames: true.
– jarmod
Aug 2 '17 at 14:04



The change to the DNS Hostnames setting can also be done using the AWS CLI:


aws ec2 modify-vpc-attribute --vpc-id $vpc_id --enable-dns-hostnames '{"Value": true}'



(Where $vpc_id is the ID of the VPC that your instance is attached to.)



As soon as the VPC is updated the instance will gain a public DNS.



After verifying VPC and Subnet settings, my EC2 instance still didn't have a public DNS. After a day of searching for a resolution, I finally figured it out.



I had to create a new Elastic IP address, then associate it to my instance.



From the EC2 Dashboard:



Go to Elastic IPs from the sidebar.



Click Allocate new address, then Allocate.



Go back to the EC2 Dashboard. Go to Network Interfaces.



Select the EC2 instance without a public DNS. Then Actions - Associate Address.



The Address field, select the new elastic IP address.



The Associate to private IP address field, select the private IP address with no public DNS.



Click Associate Address.



Your EC2 instance should now have a public DNS.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift