Help Center> Elastic Cloud Server> Troubleshooting> Configuring the Network> Why an Entry Is Automatically Added to /etc/hosts After a Linux ECS Is Restarted?
Updated on 2022-02-22 GMT+08:00

Why an Entry Is Automatically Added to /etc/hosts After a Linux ECS Is Restarted?

Symptom

After an ECS is restarted, an entry that maps its host name to 127.0.0.1 is automatically added to /etc/hosts. As a result, the host name fails to be resolved.

Root Cause

/etc/cloud/cloud.cfg affects the following configuration in /etc/hosts:

 manage_etc_hosts: localhost

This configuration automatically translates the host names to the local loopback address, which can speed up startup when the private DNS is not configured.

Solution

  1. Open the /etc/cloud/cloud.cfg file.

    Comment out manage_etc_hosts:

    Before:

    manage_etc_hosts:localhost

    After:

    #manage_etc_hosts:localhost

2. Delete 127.0.0.1 hostname hostname from /etc/hosts.