#5497 openai.APIConnectionError: Connection error.

116.25* Posted at: 2 hours ago

Connection error.:Traceback (most recent call last):
File "httpx\_transports\default.py", line 101, in map_httpcore_exceptions
File "httpx\_transports\default.py", line 250, in handle_request
File "httpcore\_sync\connection_pool.py", line 216, in handle_request
File "httpcore\_sync\connection_pool.py", line 196, in handle_request
File "httpcore\_sync\http_proxy.py", line 289, in handle_request
File "httpcore\_sync\connection.py", line 99, in handle_request
File "httpcore\_sync\connection.py", line 76, in handle_request
File "httpcore\_sync\connection.py", line 122, in _connect
File "httpcore\_backends\sync.py", line 205, in connect_tcp
File "contextlib.py", line 153, in exit
File "httpcore\_exceptions.py", line 14, in map_exceptions
httpcore.ConnectError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "openai\_base_client.py", line 1005, in request
File "httpx\_client.py", line 914, in send
File "httpx\_client.py", line 942, in _send_handling_auth
File "httpx\_client.py", line 979, in _send_handling_redirects
File "httpx\_client.py", line 1014, in _send_single_request
File "httpx\_transports\default.py", line 249, in handle_request
File "contextlib.py", line 153, in exit
File "httpx\_transports\default.py", line 118, in map_httpcore_exceptions
httpx.ConnectError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "videotrans\util\TestSrtTrans.py", line 19, in run
File "videotrans\translator\__init__.py", line 1000, in run
File "videotrans\translator\_base.py", line 100, in run
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_localllm.py", line 49, in _item_task
File "openai\_utils\_utils.py", line 286, in wrapper
File "openai\resources\chat\completions\completions.py", line 1211, in create
File "openai\_base_client.py", line 1297, in post
File "openai\_base_client.py", line 1037, in request
openai.APIConnectionError: Connection error.


=
system:Windows-10-10.0.26200-SP0
version:v3.99
frozen:True
language:zh
root_dir:E:/win-pyvideotrans-v3.99-428

3 Replies

连接错误的原因是:你配置的本地模型 API 地址对应的服务没有启动或地址填写错误。具体报错 [WinError 10061] 表示目标计算机积极拒绝连接,说明软件尝试连接某个 IP 和端口,但该端口上没有服务在监听。

解决方案:

  1. 请检查你在 菜单 → 翻译设置 → 本地大模型/兼容AI 中填写的 API 地址是否正确。必须为 http://127.0.0.1:端口号 形式,不能是 0.0.0.0(软件会自动报错并提示你修改)。
  2. 确认你的本地大模型服务(如 Ollama、LM Studio、Text Generation WebUI 等)已经启动,并且监听的端口与软件中填写的一致。
  3. 如果该地址正确,尝试在浏览器中直接访问该地址(例如 http://127.0.0.1:11434)看能否打开页面。若无法打开,说明服务未成功启动或端口被占用。
  4. 重启软件和服务后再试。

如果问题依然存在,请提供你在“本地大模型设置”中填写的 API 地址,以及你的本地模型服务名称,以便进一步排查。

前两天使用都正常,就重置网络了,关闭翻墙软件用本地国内网,现在就报错,以上错误没法解决,不知道是开始付费来从新匹配还是怎么操作?

你遇到的情况很可能是:之前通过翻墙软件可以访问境外 API(如 OpenAI、Gemini 等),现在关闭翻墙后,这些境外服务直接无法连接,所以报错。

解决方案(任选一种)

方案一:重新开启翻墙软件
如果你仍想使用原本的境外翻译渠道(例如 OpenAI、Gemini),请恢复翻墙软件,并确保软件中的代理设置正确。

  • 在主界面底部「网络代理」文本框里填写你的代理地址,例如 http://127.0.0.1:7890(具体端口以你的翻墙软件为准)。
  • 如果之前没有填代理也能用,可能是系统级代理已断开,开启翻墙软件后系统代理自动恢复即可。

方案二:改用国内可直连的翻译渠道(推荐)
如果不想用翻墙,请切换到国内可用且免费的翻译渠道:

  • 菜单 → 翻译设置 → 选择 Microsoft 翻译(无需代理)或 DeepSeek(需注册免费账号获取 API Key)或 百度翻译/腾讯翻译(需申请免费 API)。
  • 将翻译渠道切换后重新执行任务。

方案三:检查本地大模型服务
如果你配置的是本地大模型(如 Ollama),请确认该服务是否在后台运行:

  • 打开浏览器访问 http://127.0.0.1:11434,若无法打开说明服务未启动,重新运行你的本地模型服务后再试。
  • 检查菜单 → 翻译设置 → 本地大模型设置中的 API 地址是否为正确的本地地址(如 http://127.0.0.1:11434/v1)。

请先尝试以上步骤,如果仍有问题,请说明你之前使用的翻译渠道名称(例如 OpenAI、DeepSeek 还是本地模型),以及当前是否已开启翻墙软件。

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update. Dondate: ko-fi.com/jianchang512

Related resource