# dial tcp 127.0.0.1:3306: connect: connection refused

- **ID:** `go/sql-connection-refused`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Database server is not running or not listening on the specified port.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Check if server is up before connecting: net.DialTimeout("tcp", addr, 5*time.Second)
   ```
2. **** (85% success)
   ```
   Use connection retry with backoff: for i:=0; i<5; i++ { db, err := sql.Open(...); if err==nil { break }; time.Sleep(time.Duration(i)*time.Second) }
   ```

## Dead Ends

- **** — If server is down, it blocks forever. (70% fail)
- **** — Server may not use default port. (40% fail)
