Possible causes

A possible cause is that the host name or host IP address cannot be correctly retrieved. To verify this assumption, run the hostname command.

If the host name cannot be correctly retrieved, the assumption is true. Otherwise, this issue may have been caused by another reason. In this case, to seek help from Customer Services.

Recommended solution

Perform the following steps:

  1. On the machine for which the error is reported, run the following command to check the host name.
    [root@iZ231wxgt6mZ ~]# hostname
    iZ231wxgt6mZ                  

    If an error is reported, check whether an alias has been defined for the host name, for example, alias xxx='hostname' in .bash_profile or .bashrc. It is also possible that the command path is not under $PATH.

  2. Ping the host.
        [root@iZ231wxgt6mZ ~]# ping iZ231wxgt6mZ         

    If the host name cannot be pinged, add the local IP address to the /etc/hosts file. Each Elastic Compute Service (ECS) instance establishes a binding relationship between the local IP address and the host name by default. Do not remove it manually.

  3. Check the system configuration.

    Check whether the host name recorded in /etc/sysconfig/network is consistent with that added to /etc/hosts. If not, modify the host name. After the content in /etc/sysconfig/network has been modified, you must restart the instance so that the modification can take effect. Exercise caution when you modify configurations in a system file, as doing so may cause other exceptions.

After the preceding steps are performed, the UnknownHostException error will not be returned again when the client starts.