405 method not allowed is what Ollama answers when /api/generate
or /api/chat gets a GET request, which is what curl sends
without -d and also what a browser sends when you paste the address. These endpoints take POST with a JSON body; the response
even says so in its Allow: POST header.
Send the request with a body (curl.exe -d "@file.json" makes curl use POST),
and to check that the server is up with a GET, use the root URL or
/api/tags instead: both answered GET with 200.
The error
PS> curl.exe -i http://127.0.0.1:15190/api/generate
HTTP/1.1 405 Method Not Allowed
Allow: POST
Content-Type: text/plain
Date: Fri, 13 Nov 2026 05:37:23 GMT
Content-Length: 22
405 method not allowed
/api/chat gave the same status line, headers and body.
Why it happens
curl.exe -i with no -d sent GET, the same method a pasted
address sends. The generate and chat endpoints accept POST, so the server answered 405
and listed the method it wants in Allow. The body is the plain text
405 method not allowed with Content-Type: text/plain, not a JSON
error object, so read the status code before you parse the body.
The other GET routes behave differently, which makes them useful for a quick check:
PS> curl.exe -i http://127.0.0.1:15190/
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Fri, 13 Nov 2026 05:37:23 GMT
Content-Length: 17
Ollama is running
PS> curl.exe -i http://127.0.0.1:15190/api/tags
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Fri, 13 Nov 2026 05:37:24 GMT
Transfer-Encoding: chunked
{"models":[{"name":"fix-tplok:latest","model":"fix-tplok:latest",...
The root says the server is running; /api/tags lists the models on it. So a
405 is good news of a kind: it proves the server is up and the path exists. In the same
test a wrong path, /api/nosuch, answered 404 page not found, and
a port with no server gave curl: (7) Failed to connect. Only the method needs
to change.
The fix
{"model":"qwen2.5:0.5b","prompt":"Say hi","stream":false}
PS> curl.exe -s -i http://127.0.0.1:15190/api/generate -d "@../json/gen-ok.json"
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Fri, 13 Nov 2026 05:39:08 GMT
Content-Length: 581
{"model":"qwen2.5:0.5b","created_at":"2026-11-13T05:39:08.3533894Z","response":"Hello! It's nice to meet you. How can I...
With -d curl sent POST and the body from the file, and the answer was 200
with JSON. In code, use the POST method of your HTTP client and send the same JSON.
How it was reproduced
On Windows 11 in Windows PowerShell 5.1 with curl 8.22.0 and Ollama 0.40.16, against a
separate test server on 127.0.0.1:15190 with its own models folder.
curl.exe -i sent GET to /api/generate, /api/chat,
/ and /api/tags; then a body written to a file with
[IO.File]::WriteAllText was posted to /api/generate. curl's
progress meter lines were removed from the captures.
Frequently asked
- Why does Ollama's /api/generate answer 405 method not allowed to a GET?
- The request used GET, as a pasted address does, and the generate endpoint takes POST. In the test the answer was 405 with an Allow: POST header. Send a POST with a JSON body instead.
- How do I check with a GET request that Ollama is running?
- Request the root URL. In the test GET / answered 200 with the text Ollama is running, and GET /api/tags answered 200 with the list of models.
- Does /api/chat accept GET?
- No. In the test with Ollama 0.40.16, GET /api/chat answered 405 Method Not Allowed with Allow: POST, the same as /api/generate.
More decoded errors in the Fixes category. When the POST arrives with nothing in it, see Ollama API: 'missing request body'.