# java.net.ConnectException: Connection refused

**Code:** `ConnectException` · **Category:** Java · **Seen on:** Java

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/java/connectexception-connection-refused)
