Skip to content
MtrXTools

java.net.ConnectException: Connection refused

Nothing is listening on that port

Seen in Java, Spring, Kafka, JDBC drivers, Android

The host actively refused the TCP connection because no process is listening on that address and port.

Common causes

  • The service is down or listens on another port.
  • The service binds to 127.0.0.1 only, but the client connects from another host or container.
  • Inside a container or Android emulator, localhost is not the machine you think it is.
  • A firewall rejects the connection.

How to fix it

  1. Check the service is running and listening (ss -ltnp).
  2. Bind the service to 0.0.0.0 or the right interface.
  3. Use the service name in Docker, or 10.0.2.2 for the host from the Android emulator.
Check the port from outside

Got a different message? Paste it into the error explainer.

Related errors

All 32 Languages & runtimes errors