How to Fix Connection refused: connect Connection refused: connect

1. Error as above.
2. Reasons and Solutions:
1) The port number is occupied: kill the process occupying the port number (generally 8080) and release the port; Shut down the Tomcat server completely, or restart the project.
2) Use the following command to check the maximum number of processes allowed on the server: ulimit-u. If this value is set to a lower value, such as 1024, then increase it to 131072 or unrestricted with the following value: ulimit-u 131072 or ulimit-u unrestricted.
3) Client and server, either or both of which are not in the network.
They may not be connected to a LAN or the Internet or any other network, in which case Java will be thrown
The client “ refused” exception.

4) server not running
The server is down but not running. In this case, you will also get connection refused error. Ping to check if the server is running and listening on the port.

5) server running but not listening port, client trying to connect.
The server is running but listening on a different port. Verify the configuration. If you are working on a large project and have a hierarchical configuration file, it may be the default configuration or some other Settings overwrite your correct Settings.
6) Host port combination is not allowed to use firewall
Almost every corporate network is protected by a firewall. If you are connecting to other corporate networks, such as in any electronic trading system, you need to improve the firewall
Both parties are required to ensure that they allow each other’s IP address and port number. If the firewall is not allowed to connect, will also receive the same connection refused to abnormal in application.
7) Incorrect host port combination.
The host port combination provided is incorrect, or the earlier host port combination on the server side has changed. Check the latest configuration on both the client and server sides.
8) The protocol in the connection string is incorrect
TCP is the basis for many advanced protocols, including HTTP, RMI, and so on. Through the connection string, you need to make sure that you pass the correct protocol that the server expects. For example, if the server is exposed, a service that passes through RMI instead of a connection string should start with RMI: //.
3. My situation:
, my reason is relatively simple, which probably belongs to the 5th, 7th and 8th points above, but the configuration is not correct anyway. I just miswrote the IP address of the server where the database is located.


July 4, 2019:
From the comments:
“The same can happen if all parameters are not added to the comment.”
Join the article, for reference, also very grateful to this friend: ‘Seven.

Read More: