amazon-web-services - ubuntu1604 - unable to resolve the host name
AWS error-sudo: unable to resolve host ip-10-0-xx-xx (6)
I launched a new
instance. My private ip is
as per amazon console. Everytime when I do a sudo command, I get the following error
sudo: unable to resolve host ip-10-0-xx-xx
How can I rectify this error?
Can patch easily from command line as follows:
sudo sed -i /etc/hosts -e "s/^127.0.0.1 localhost$/127.0.0.1 localhost $(hostname)/"
And checked that a reboot, or stop, then start the aws instance would preserve it. In case it is lost, can easily re-apply on boot, and can be added to any provision for new vms.
[email protected]:~$ sudo id sudo: unable to resolve host ip-177-11-22-333 uid=0(root) gid=0(root) groups=0(root)
[email protected]:~$ sudo sed -i /etc/hosts -e "s/^127.0.0.1 localhost$/127.0.0.1 localhost $(hostname)/" sudo: unable to resolve host ip-177-11-22-333
[email protected]:~$ sudo id uid=0(root) gid=0(root) groups=0(root) [email protected]:~$
It seems that it cannot resolve the host so you can help it by adding this line to the /etc/hosts
The below answer with enableDnsHostnames is a better solution through
This issue is caused by not enabling
in your VPC configuration.
Indicates whether the instances launched in the VPC get DNS hostnames. If this attribute is true, instances in the VPC get DNS hostnames; otherwise, they do not. If you want your instances to get DNS hostnames, you must also set the
enableDnsSupportattribute to true.
This worked for me:
Add the following line to
The ip thing is your private ip address
Enabling the DNS hostnames for your VPC, so all the instances launched within the VPC will resolve the host
Edit /etc/hosts and add the below line
127.0.0.1 localhost 184.108.40.206 ip-10-0-1-18 ## (Replace with the private ip)
This is something you will need to do for every instance that will be launch within your VPC.
as described in Michael's comment is one prerequisite. The other is having your VPC's
DHCP option set configured correctly
. The problem you are coming up against is caused by
line missing from your
; it will be put in there at the time of DHCP assignment if you set
of your DHCP option set appropriately. Read the linked AWS doc.