# 错误：无法连接到远程主机：拨号 tcp <ip>:22：连接被拒绝

- **ID:** `terraform/provisioner-connection-refused`
- **领域:** terraform
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

Terraform provisioner 无法建立 SSH 连接，因为远程主机未在端口 22 上监听或 IP 不可达。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.4.0 | active | — | — |
| 1.5.0 | active | — | — |
| 1.6.0 | active | — | — |

## 解决方案

1. ```
   验证安全组允许端口 22 的入站流量，并且实例具有公共 IP。使用 'ssh -vvv user@ip' 测试连接。
   ```
2. ```
   检查实例是否已启动并且 SSH 服务正在运行。使用 cloud-init 日志或控制台输出进行验证。
   ```

## 无效尝试

- **** — Simply retrying the apply command does not resolve the underlying network issue; the host is still unreachable. (95% 失败率)
- **** — Adding more timeout in the connection block does not fix the refusal; it only delays the failure. (70% 失败率)
