Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)
edited by

I was trying to implement a TCP connection, but it throwing an error when I am using it from the client side. Error:

java.net.ConnectException: Connection refused

        at java.net.PlainSocketImpl.socketConnect(Native Method)

        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)

        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)

        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)

        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)

        at java.net.Socket.connect(Socket.java:529)

        at java.net.Socket.connect(Socket.java:478)

        at java.net.Socket.<init>(Socket.java:375)

        at java.net.Socket.<init>(Socket.java:189)

        at TCPClient.main(TCPClient.java:13)

Can anyone help me why this error showed up?

1 Answer

0 votes
by (26.7k points)

This exception shows up because there is no service that is listening to the port, for which you are trying to connect:

- Check with the IP/Host or port.

- You may not be started your server.

- Also, your server may not be listening to connections.

- The backlog queue is full for the Windows server.

I hope this will help.

Want to become a Java expert? join Java Course now!!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...