Ollama request failed: HTTPConnectionPool(host='localhost', port=11434): Max ret...

2025年10月01日 16:59 响应: 1.72秒 状态: success

🚨 错误信息

Ollama API error: Ollama request failed: HTTPConnectionPool(host='localhost', port=11434): Max retries exceeded with url: /api/generate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000027671AE0050>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。')) Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

🤖 AI解决方案

Ollama API error: Ollama request failed: HTTPConnectionPool(host='localhost', port=11434): Max retries exceeded with url: /api/generate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000027671AE0050>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

错误翻译

Ollama API 错误:Ollama 请求失败:HTTPConnectionPool(host='localhost', port=11434):URL /api/generate 的最大重试次数已用尽(由 NewConnectionError 引起:'<urllib3.connection.HTTPConnection object at 0x0000027671AE0050>': 无法建立新连接:[WinError 10061] 由于目标计算机积极拒绝,无法连接。)

原因分析

Ollama 服务未在 localhost:11434 上运行或无法访问。

解决方案

  • 启动 Ollama 服务:请确保 Ollama 服务已在您的本地计算机上运行。
  • * 如果您使用的是 Ollama 应用程序,请检查其是否正在运行。 * 如果您通过命令行安装,请运行 ollama serve 命令。
  • 检查端口:确认 Ollama 服务确实监听在 11434 端口。
  • 预防措施

  • 在尝试与 Ollama API 交互前,始终确保 Ollama 服务已启动并可访问。

  • 考虑在代码中添加一个检查,验证 Ollama 服务是否正在运行,并在服务未运行时提供友好的错误提示。