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
- Check the target is up and listening
- Fix host/port configuration
- Use the compose service name in containers
Detailed fix by platform
Java
- Spring Boot: verify spring.datasource.url / spring.data.redis.host per environment
How to diagnose
- Target — host:port
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026