DEV Community

Jelly Eclipse
Jelly Eclipse

Posted on

java.net.ConnectException: Connection refused

Three checks:
1) Run the Server code before running the Client code.
2)instead of this Socket clientSocket = new Socket("localhost", 5000);

do

Socket clientSocket = new Socket("127.0.0.1", 5000);

3)While hitting the url don't type "https://" type "http://"

Hope above might help the beginners those who are trying to connect client and server on the same computer

For those who are trying to connect to the other server rather than local

check for firewall blocking the connection or it might the listen backlog queue is full.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay