Birendra
Birendra

Reputation: 121

Why am I getting " java.net.ConnectException: Connection refused: connect"?

I am trying to make a simple socket to my loopback address -

Socket socket = new Socket("127.0.0.1", 4424); 

when i get this exception. How do i resolve it?

Upvotes: 0

Views: 113

Answers (2)

Davide Lorenzo MARINO
Davide Lorenzo MARINO

Reputation: 26926

Have you a socket server listening on port 4424?

You are creating a socket client. It can communicate only with a running socket server on the same port.

If you like you can create a server in java using the ServerSocket class.

Upvotes: 3

Ketan G
Ketan G

Reputation: 517

Your socket server is not listening to localhost.Make sure that u have socket server on ur machine nd if not please download it .

Upvotes: 0

Related Questions