java.net.ConnectException: 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 “java.net.ConnectException:Connection refused” exception.
4) server not running
The server is down but not running. In this case, you will also get java.net.ConnectException: 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 java.net.ConnectException:Java 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.
spring.datasource.url=jdbc:mysql://数据库所在服务器IP:3306/gaei_ms?useUnicode=true&characterEncoding=utf-8&useSSL=false
———————————————————————————————
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.
Reference: https://javarevisited.blogspot.com/2013/02/java-net-ConnectException-Connection-refused.html
Read More:
- solve java.net.ConnectException : Connection refused:connect report errors
- JMeter performance test monitoring server resource reported error: java.net.ConnectException : Connection refused: connect
- hdfs 192.168.2.19:9000 failed on connection exception: java.net.ConnectException:Connection refused
- Error: JMeter monitors Linux system performance java.net.ConnectException : Connection timed out: connect
- Solve the java.net.connectexception: connection rejected: connect error
- [resolved] exception java.net.ConnectException : Error opening socket to server Connection timed out.
- Zookeeper starts the client and reports an error: java.net.connectexception: connection rejected
- Java connection SQL error, network error IO Exception:Connection refused :connect
- Solve the problem of Failed to load resource: net::ERR_CONNECTION_REFUSED
- failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
- Nginx reports 502 error, log connect() failed (111: Connection refused) while connecting to upstream. A personal effective solution
- curl: (7) Failed connect to localhost:9200; Connection refused
- error: \*1035 connect() failed (111: Connection refused) while connecting to upstream, client…..
- 【MongoDB】 Failed to connect to 127.0.0.1:27017, reason: Connection refused
- Failed to load resource: net::ERR_CONNECTION_REFUSED
- curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
- failed to connect to ‘192.168.199.143:5555‘: Connection refused
- Zookeeper connection timeout problem, and refused to connect to solve the problem
- 【Synergy】Error:failed to connect to server:Connection was refused
- samba Error NT_STATUS_CONNECTION_REFUSED Failed to connect with SMB1 — no workgroup available