# E: 无法在端口 8080 上监听：监听器创建失败，错误信息：[无法创建监听器：错误监听 tcp4 127.0.0.1:8080：绑定：地址已在使用中]

- **ID:** `kubernetes/port-forward-connection-refused`
- **领域:** kubernetes
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

本地端口（例如 8080）已被其他进程占用，阻止了 kubectl port-forward 的绑定。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| kubernetes 1.25 | active | — | — |
| kubectl 1.26 | active | — | — |
| kubectl 1.27 | active | — | — |

## 解决方案

1. ```
   识别占用端口（例如 8080）的进程并终止：`lsof -i :8080` 然后 `kill -9 <PID>`。或者使用 `fuser -k 8080/tcp`。
   ```
2. ```
   使用未被占用的不同本地端口：`kubectl port-forward pod/my-pod 9090:80`（将本地 9090 映射到 pod 的 80）。使用 `netstat -tuln | grep 9090` 验证。
   ```

## 无效尝试

- **** — Restarting the command doesn't release the port; the local process still holds it. (95% 失败率)
- **** — If the new port is also in use, the same error occurs. Requires manual verification. (30% 失败率)
- **** — Elevated privileges don't free the port; the underlying socket is still bound. (90% 失败率)
