1. The “java.net.ConnectException: Connection refused: connect” error
2. Causes and solutions:
1) The port number is occupied: kill the process with 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 in the server: ulimit -u. If this value is set to a low value, such as 1024, 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 could not connect to the LAN or the Internet or any other network, in this case, Java will be thrown
client “java.net.ConnectException:Connection refused” exception.
means the server is down but not running. In this case, you will also get java.net.ConnectException: connection refused error. You can ping to check if the server is running and listen for ports.
5) The server is running but not listening. The client is trying to connect.
The server is running but is listening on a different port. Verify the configuration. If you are working on a large project and have a tiered configuration file, it may be the default configuration or some other setting that overrides your correct Settings.
6) The host port combination is not allowed to use firewalls
Almost every corporate network is protected by a firewall. If you are connecting to other corporate networks, for example in any electronic trading system, need to raise the firewall
both parties require to ensure they allow each other’s IP addresses and port numbers. If the firewall is not allowed to connect, will also receive the same java.net.ConnectException:Java connection refused to abnormal in application.
7) The host port combination is incorrect.
provides an incorrect host port combination, or an earlier host port combination has changed on the server side. Check the current configuration on both the client and server sides.
8) Incorrect protocol in connection string
TCP is the basis of many high-level protocols, including HTTP, RMI, and so on. By connecting to strings, you need to make sure you pass the correct protocol that the server expects. For example, if the server is exposed, a service that passes through RMI rather than a connection string should start with RMI: //.
above is baidu to find the reason and solution, and I met wrong very low-level: didn’t start Tomcat.
The diagram below:
If Tomcat runs main without starting, it will report the following error:
Then you need to start Tomcat as shown below:
Then you can execute the code:
2. Causes and solutions:
1) The port number is occupied: kill the process with 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 in the server: ulimit -u. If this value is set to a low value, such as 1024, 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 could not connect to the LAN or the Internet or any other network, in this case, Java will be thrown
client “java.net.ConnectException:Connection refused” exception.
means the server is down but not running. In this case, you will also get java.net.ConnectException: connection refused error. You can ping to check if the server is running and listen for ports.
5) The server is running but not listening. The client is trying to connect.
The server is running but is listening on a different port. Verify the configuration. If you are working on a large project and have a tiered configuration file, it may be the default configuration or some other setting that overrides your correct Settings.
6) The host port combination is not allowed to use firewalls
Almost every corporate network is protected by a firewall. If you are connecting to other corporate networks, for example in any electronic trading system, need to raise the firewall
both parties require to ensure they allow each other’s IP addresses and port numbers. If the firewall is not allowed to connect, will also receive the same java.net.ConnectException:Java connection refused to abnormal in application.
7) The host port combination is incorrect.
provides an incorrect host port combination, or an earlier host port combination has changed on the server side. Check the current configuration on both the client and server sides.
8) Incorrect protocol in connection string
TCP is the basis of many high-level protocols, including HTTP, RMI, and so on. By connecting to strings, you need to make sure you pass the correct protocol that the server expects. For example, if the server is exposed, a service that passes through RMI rather than a connection string should start with RMI: //.
above is baidu to find the reason and solution, and I met wrong very low-level: didn’t start Tomcat.
The diagram below:
If Tomcat runs main without starting, it will report the following error:
Then you need to start Tomcat as shown below:
Then you can execute the code:
Read More:
- How to Fix java.net.ConnectException: Connection refused: connect
- JMeter performance test monitoring server resource reported error: java.net.ConnectException : Connection refused: connect
- Solve the java.net.connectexception: connection rejected: connect error
- 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
- [resolved] exception java.net.ConnectException : Error opening socket to server Connection timed out.
- Running Django manager.py report errors Error:111 connecting to 127.0.0.1:6379.connection refused
- Zookeeper starts the client and reports an error: java.net.connectexception: connection rejected
- Solve the problem of Failed to load resource: net::ERR_CONNECTION_REFUSED
- Java connection SQL error, network error IO Exception:Connection refused :connect
- failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
- Zookeeper connection timeout problem, and refused to connect to solve the problem
- Nginx reports 502 error, log connect() failed (111: Connection refused) while connecting to upstream. A personal effective solution
- error: \*1035 connect() failed (111: Connection refused) while connecting to upstream, client…..
- curl: (7) Failed connect to localhost:9200; Connection refused
- Solve the MAC terminal download error curl: (7) failed to connect to raw.githubusercontent.com port 443: Connection refused
- Failed to load resource: net::ERR_CONNECTION_REFUSED
- 【MongoDB】 Failed to connect to 127.0.0.1:27017, reason: Connection refused
- Caused by: java.net.SocketException : connection reset or caused by: java.sql.SQLRecoverableException solve
- curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused