`Temporary failure in name resolution` on freshly created AWS EC2 instance

Viewed 3574

I am new to AWS.

I had another issue with an instance, so I decided that I delete it and redo the steps to create a new one:

  1. Define a key pair;
  2. Create a stack from a template;
  3. Access the instance with ssh;
  4. Install apps I want to use.

Here is the template I use

Resources:
  AppNode:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t2.nano
      ImageId: ami-06a719e5f8e22c33b
      KeyName: influxdb_example_3
      SecurityGroups:
        - !Ref AppNodeSG
      UserData: !Base64 |
        #!/bin/bash
        apt-get update -qq
        apt-get install -y apt-transport-https ca-certificates
        apt-key adv apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
        apt-get update -qq apt-get purge lxc-docker || true
        curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
        add-apt-repository "deb [arch=amd65] https://download.docker.com/linux/ubuntu bionic stable"
        apt-get -y install linux-image-extra-$(uname -r) linux-image-extra-virtual
        apt-get -y install docker-ce
        usermod -aG docker unbuntu
        docker image pull quay.io/influxdb/influxdb:v2.0.2
        docker container run -p 80:9999 quay.io/influxdb/influxdb:v2.0.2
  AppNodeSG:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: for the app nodes that allow ssh
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: "80"
          ToPort: "80"
          CidrIp: 0.0.0.0/0
        - IpProtocol: tcp
          FromPort: "22"
          ToPort: "22"
          CidrIp: 0.0.0.0/0

This is how I create the stack

aws cloudformation create-stack \
  --stack-name influxdb-trial-stack-2 \
  --region eu-central-1 \
  --template-body file://$PWD/stack.yaml

And this is how I access it:

ssh -i influxdb_example_3.pem \
    ubuntu@ec2-18-159-XXX-XX.eu-central-1.compute.amazonaws.com

I manage to create the stack/instance and access it. Since the second attempt, however, whenever I try to do anything there with sudo it reacts very slowly and I got the unable to resolve host ip-172-31-xx-xxx: Temporary failure in name resolution message. I have gone through the steps three times already, but it always comes down to this.

The nearest thing I found was here: https://forums.aws.amazon.com/thread.jspa?threadID=132414.

Based on that, I inserted the private ip/dns into etc/hosts, but it did not help (though it talks about 'network restart'. Is it the same as instance reboot?)

I understand that there are different manual ways to fix this issue, but as in the first time it did work for me, and as I would assume that the stack creation process is automatic, I suspect that there is some config/cache/??? issue I am not aware of.

Any suggestions are appreciated.

2 Answers

It turned out that using a different AMI solved the issue.

My second and further setups used a different AMI from the first just I forgot about this and did not even think that the AMI could be the problem.

For anyone having issues like this on an Ubuntu AMI, or an instance that previously could connect, it may be a hardware issue.

I had the same error with an instance (and ruled out the DNS lookup limit). After some time I stumbled on an AWS support thread indicating that it could be a hardware problem.

The physical underlying host of your instance (i-3d124c6d) looks to have intermittently been having a issues, some of which would have definitely caused service interruption.

Could you try stopping and starting this instance? Doing so will cause it to be brought up on new underlying hardware and then we could utilize your pingdom service to verify if further issues arise.

from: https://forums.aws.amazon.com/thread.jspa?threadID=171805.

Stopping and restarting the instance resolved the issue for me.

Related