# RuntimeError: Connection refused: The server is not running or is unreachable.

- **ID:** `python/starlette-runtime-error-connection-refused`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to connect to a Starlette server that is not started or is listening on a different host/port.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Start server with correct host and port** (90% success)
   ```
   uvicorn app:app --host 0.0.0.0 --port 8000
# Then connect to http://localhost:8000
   ```
2. **Check firewall and network settings** (80% success)
   ```
   sudo ufw status
# Allow port if needed: sudo ufw allow 8000
   ```

## Dead Ends

- **Checking only localhost without specifying port** — Server may be on a different port or bound to 0.0.0.0. (70% fail)
- **Using wrong protocol (http vs https)** — If server uses SSL, http connections fail. (60% fail)
