An Enterprise Distributed Application Service (EDAS) application fails to start and throws UnknownHostException. This topic explains the cause and provides steps to resolve the issue.
Symptom
The application fails to start in the EDAS console with the following error:
UnknownHostExceptionCause
The hostname of the machine was changed, but /etc/hosts was not updated to reflect the new name.
During startup, the Java runtime calls InetAddress.getLocalHost() to resolve the local hostname. If the current hostname has no matching entry in /etc/hosts, the lookup fails and throws UnknownHostException.
Solution
Add the current hostname to /etc/hosts so that the Java runtime can resolve it.
Step 1: Check the current hostname
Run the following command to display the current hostname:
hostnameExample output:
my-edas-nodeStep 2: Check /etc/hosts for a matching entry
cat /etc/hostsIf the output does not contain a line that maps the hostname (my-edas-node in this example) to an IP address, the entry is missing.
Step 3: Add the hostname to /etc/hosts
Open /etc/hosts and add a line that maps 127.0.0.1 to the current hostname:
echo "127.0.0.1 $(hostname)" | sudo tee -a /etc/hostsAfter the edit, /etc/hosts should contain a line similar to:
127.0.0.1 my-edas-nodeStep 4: Verify the fix
Confirm that the hostname resolves:
ping -c 1 $(hostname)A successful response confirms that the hostname now resolves to an IP address.
Restart the application in the EDAS console and verify that it starts without the
UnknownHostExceptionerror.
Prevent recurrence
When you change the hostname on a machine that runs EDAS applications, always update /etc/hosts at the same time to keep the two in sync.
If the issue persists
If the application still fails to start after you update /etc/hosts, check the application logs in the EDAS console for other errors.