[GH-ISSUE #5483] Endpoints should return 405 Method Not Allowed rather than 404 for unsupported methods #3429

Closed
opened 2026-04-12 14:05:15 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @TheEpic-dev on GitHub (Jul 4, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5483

Originally assigned to: @royjhan on GitHub.

What is the issue?

As mentioned on Discord, it's no big deal, but sometimes users make mistakes like opening http://127.0.0.1:11434/api/chat in a browser, which defaults to the GET method, and are served a 404 page.

As the resource presumably does exist and works with POST requests, returning a 405 Method Not Allowed would be a more accurate response to the user's error.

I have tested this on the /api/chat and /api/generate endpoints, as well as the /api/ps endpoint with a POST request, but I presume most, if not all, endpoints return a 404 page when queried with the wrong method.

Steps to reproduce:

curl -v http://127.0.0.1:11434/api/chat
*   Trying 127.0.0.1:11434...
* Connected to 127.0.0.1 (127.0.0.1) port 11434
> GET /api/chat HTTP/1.1
> Host: 127.0.0.1:11434
> 
< HTTP/1.1 404 Not Found
...

curl -v 127.0.0.1:11434/api/ps -d '{}'
*   Trying 127.0.0.1:11434...
> POST /api/ps HTTP/1.1
> Content-Length: 2
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 2 bytes
< HTTP/1.1 404 Not Found

Cheers, Pat

OS

Linux

GPU

AMD

CPU

AMD

Ollama version

0.1.46

Originally created by @TheEpic-dev on GitHub (Jul 4, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5483 Originally assigned to: @royjhan on GitHub. ### What is the issue? As mentioned on Discord, it's no big deal, but sometimes users make mistakes like opening `http://127.0.0.1:11434/api/chat` in a browser, which defaults to the GET method, and are served a `404` page. As the resource presumably does exist and works with POST requests, returning a `405` *Method Not Allowed* would be a more accurate response to the user's error. I have tested this on the `/api/chat` and `/api/generate` endpoints, as well as the `/api/ps` endpoint with a POST request, but I presume most, if not all, endpoints return a `404` page when queried with the wrong method. Steps to reproduce: ``` curl -v http://127.0.0.1:11434/api/chat * Trying 127.0.0.1:11434... * Connected to 127.0.0.1 (127.0.0.1) port 11434 > GET /api/chat HTTP/1.1 > Host: 127.0.0.1:11434 > < HTTP/1.1 404 Not Found ... curl -v 127.0.0.1:11434/api/ps -d '{}' * Trying 127.0.0.1:11434... > POST /api/ps HTTP/1.1 > Content-Length: 2 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 2 bytes < HTTP/1.1 404 Not Found ``` Cheers, Pat ### OS Linux ### GPU AMD ### CPU AMD ### Ollama version 0.1.46
GiteaMirror added the bugapi labels 2026-04-12 14:05:15 -05:00
Author
Owner

@jmorganca commented on GitHub (Jul 4, 2024):

@royjhan this is a great one to look at once we merge the OpenAI compatibility improvements

<!-- gh-comment-id:2209299151 --> @jmorganca commented on GitHub (Jul 4, 2024): @royjhan this is a great one to look at once we merge the OpenAI compatibility improvements
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#3429