python
network_error
ai_generated
true
RuntimeError: 连接被拒绝:服务器未运行或无法访问。
RuntimeError: Connection refused: The server is not running or is unreachable.
ID: python/starlette-runtime-error-connection-refused
80%修复率
82%置信度
0证据数
2024-07-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
尝试连接到未启动或正在侦听不同主机/端口的 Starlette 服务器。
English
Attempting to connect to a Starlette server that is not started or is listening on a different host/port.
解决方案
-
90% 成功率 Start server with correct host and port
uvicorn app:app --host 0.0.0.0 --port 8000 # Then connect to http://localhost:8000
-
80% 成功率 Check firewall and network settings
sudo ufw status # Allow port if needed: sudo ufw allow 8000
无效尝试
常见但无效的做法:
-
Checking only localhost without specifying port
70% 失败
Server may be on a different port or bound to 0.0.0.0.
-
Using wrong protocol (http vs https)
60% 失败
If server uses SSL, http connections fail.