java.net.BindException: Cannot assign requested address: JVM_Bind

Scenario

Sometimes while trying to start the Testsigma Agent using the startup script, we might face errors in Apache Tomcat Server startup due to IP conflict. The error message looks somewhat similar to the ones shown below:

SEVERE [main] org.apache.catalina.core.StandardServer.await StandardServer.await: create[localhost:8005]: 
java.net.BindException: Cannot assign requested address: JVM_Bind


Cause

This usually happens when Apache Tomcat is not able to assign the requested address for the socket. A common cause for this issue is IP Conflict due to inconsistency in the System's Hosts file.


Resolution

Check the 'hosts' file for inconsistencies

Check the 'hosts' file of your System to see if there are any inconsistencies due to duplication. Here are the common Host file locations for various Operating Systems:
For Linux - /etc/hosts

For Mac - /private/etc/hosts

For Windows - C:\Windows\System32\drivers\etc\hosts


Steps to fix:

1. First of all, backup the existing hosts file.

2. Open the hosts file using a text editor with admin privileges.

3. Check if there are multiple IP Addresses bound to the 'localhost' i.e multiple lines with the text 'localhost' in it. The following default entries are permissible and can be neglected.

127.0.0.1     localhost
::1    localhost

4. If there are additional lines containing the 'localhost' part, please comment those lines by putting a '#' in the beginning of the lines and save the file.

5. Try starting the Testsigma Agent again. If the error is resolved, please contact your System/Network Administrator to confirm if the commented line is relevant. If not, you may remove the line or keep it commented.


Happy Test Automation!