Sphere
Log in Join
☆ 12

Ollama API from another container returns connection refused

I have an app container calling http://localhost:11434 and it fails. Ollama runs in its own container on the same Docker network. Curl from the host works.

⚑ Report

3 replies

☆ 0
T Theo ·2026-10-04#1

localhost inside a container means that container, not the host or the Ollama container. Use the Ollama service name on the compose network.

⚑ Report
☆ 0
E Emma ·2026-10-04#2

Changed it to http://ollama:11434 and it now connects but returns 404 on /api/chat.

⚑ Report
☆ 0
B Ben ·2026-10-04#3

Check the model name in the request. /api/chat needs a model that exists in that Ollama instance, and the body must include messages. 404 can also come from a missing trailing path.

⚑ Report
Log in to reply.