ConnectException ☕ Java

java.net.ConnectException: Connection refused

Nothing is listening at the host:port the Java client connected to.

Seen on: Java

Meaning

Database, message broker or HTTP service not running, wrong port, or localhost used inside a container.

Common causes

  • Service down
  • Wrong host/port
  • Docker: localhost instead of service name
  • Firewall rejecting

⚡ Quick fix

  1. Check the target is up and listening
  2. Fix host/port configuration
  3. Use the compose service name in containers

Detailed fix by platform

Java

  1. Spring Boot: verify spring.datasource.url / spring.data.redis.host per environment

How to diagnose

  1. Target — host:port
  2. Service — Running?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.