Troubleshoot "[Errno 111] Connection refused" error when installing Tomcat plugins

Troubleshoot "[Errno 111] Connection refused" error when installing Tomcat plugins

When installing Tomcat plugins, you may encounter the following error: 
We failed to reach a server. Reason: [Errno 111] Connection refused: This error indicates that your client is unable to establish a connection to the Tomcat Manager URL, but the connection is not being accepted by the Tomcat server. The Tomcat Manager application is typically used to manage and deploy web applications on a Tomcat server. 
Here are some ways you can troubleshoot and resolve this issue:
  1. Check the status of Tomcat: Verify if Tomcat is up and running by accessing its default page using a web browser: http://localhost:8080. If you cannot reach the default Tomcat page, this suggests potential issues with Tomcat itself.

  2. Validate the Tomcat Manager configuration: Ensure that the Tomcat Manager application is configured correctly. Check the <Context> element for the Tomcat Manager in the server.xml configuration file. The configuration should look like this:
    <Context path="/manager" docBase="manager" privileged="true"/>

    Also, in the server.xml file, look for the Connector configuration for the HTTP connector. Ensure that the address attribute is set to 0.0.0.0 to allow connections from any IP address. For example:
    <Connector port="8080" protocol="HTTP/1.1" address="0.0.0.0" ... />

  3. Confirm the Tomcat Manager application path:  If you're trying to access the Tomcat Manager application at a specific context path (e.g., /manager), ensure that the path is correct and aligns with the configuration in the server.xml file.

  4. Verify the port setting of Tomcat Manager: Check the configuration of Tomcat Manager to confirm that it is listening on the designated port (typically port 8080). If you have customized Tomcat to use a different port, ensure you use the appropriate URL.

  5. Restart Tomcat: Sometimes, a straightforward restart of Tomcat can effectively resolve temporary issues contributing to the connection problem.

  6. Check for context path conflicts: If you have additional applications deployed on Tomcat that might clash with the Tomcat Manager's context path, it could result in issues. Ensure that there are no conflicting configurations.

  7. Test connectivity: You can try to test connectivity to confirm there are no issues using curl.
    For example:
    curl http://localhost:8080/manager
Once you've made changes based on the checks above, restart the Site24x7 server monitoring agent or re-register the plugin. Within five minutes, you should be able to view performance metrics in Site24x7.