Connection refused — a firewall or proxy may be blocking it (ECONNREFUSED) C:\Wi...

2026年10月10日 20:16 12.47 秒 success

错误信息

API Error: Connection refused — a firewall or proxy may be blocking it (ECONNREFUSED) C:\Windows\System32>netsh advfirewall firewall add rule name="AllowPort64755" dir=in action=allow protocol=TCP localport=64755 确定。 PS C:\WINDOWS\system32> Test-NetConnection -ComputerName 127.0.0.1 -Port 64755 警告: TCP connect to (127.0.0.1 : 64755) failed ComputerName : 127.0.0.1 RemoteAddress : 127.0.0.1 RemotePort : 64755 InterfaceAlias : Loopback Pseudo-Interface 1 SourceAddress : 127.0.0.1 PingSucceeded : True PingReplyDetails (RTT) : 0 ms TcpTestSucceeded : False

AI 解决方案

🔍 报错分析

1. 🌐 错误翻译


原文:API Error: Connection refused — a firewall or proxy may be blocking it (ECONNREFUSED)
译文:API错误:连接被拒绝 — 可能被防火墙或代理阻止 (ECONNREFUSED)

2. 🎯 原因分析


从测试结果 TcpTestSucceeded: False 可以看出,端口 64755 上的连接测试失败,根本原因是:目标服务未在端口 64755 上监听,或该端口未正确对外开放。已经添加了防火墙规则,但仍然连接失败,说明问题不在本地防火墙,而是后端服务本身没有正确启动或绑定到该端口。

3. 💡 解决方案

确认服务是否真正在端口 64755 上监听:

# 查看当前端口 64755 的监听状态
netstat -ano | findstr 64755

如果没有任何进程在监听该端口,则需要检查 API 服务的启动配置,确保其绑定到 0.0.0.0:64755 或 127.0.0.1:64755。

修复后的启动示例(以 Node.js 为例):

// 显式绑定到 0.0.0.0 或 127.0.0.1
const server = app.listen(64755, '0.0.0.0', () => {
  console.log('Server running on port 64755');
});

4. 🛡️ 预防措施


  • 启动后验证监听:服务启动后第一时间用 netstat 或 ss -tlnp 确认端口确实处于 LISTEN 状态。

  • 配置与启动检查:确保 API 配置中的端口与代码硬编码端口一致,避免配置冲突导致服务绑定到错误的端口上。