[GH-ISSUE #7689] Error: 404 Client Error: Not Found for url: http://localhost:11434/api/generate #66966

Closed
opened 2026-05-04 09:05:03 -05:00 by GiteaMirror · 11 comments
Owner

Originally created by @kiran-kumar-akula on GitHub (Nov 15, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7689

What is the issue?

While trying to run llama model I am getting Error: 404 Client Error: Not Found for url: http://localhost:11434/api/generate.
I am running this in my windows 11 system with python 3.13.0 version
I have installed llama3.2:latest and it's running.

Code:
response = requests.post('http://localhost:11434/api/generate',
json={
"model": "llama3.2:latest",
"prompt": f"{system_prompt}\n\n{prompt}",
"stream": False
})

Error Output:

Ollama service is running!

  • Serving Flask app 'app'
  • Debug mode: on
    INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Running on http://127.0.0.1:3000
    INFO:werkzeug:Press CTRL+C to quit
    INFO:werkzeug: * Restarting with stat
    Checking Ollama service...
    Ollama service is running!
    WARNING:werkzeug: * Debugger is active!
    INFO:werkzeug: * Debugger PIN: 119-213-946
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:53] "GET / HTTP/1.1" 200 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:53] "GET /api/history HTTP/1.1" 200 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:53] "GET /favicon.ico HTTP/1.1" 404 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:55] "GET /api/health HTTP/1.1" 200 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:55] "GET /api/history HTTP/1.1" 200 -
    ERROR:main:Error in Ollama request: 404 Client Error: Not Found for url: http://localhost:11434/api/generate
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:09:01] "POST /api/chat HTTP/1.1" 200 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:37] "GET / HTTP/1.1" 200 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:38] "GET /api/history HTTP/1.1" 200 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:40] "GET /api/health HTTP/1.1" 200 -
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:40] "GET /api/history HTTP/1.1" 200 -
    ERROR:main:Error in Ollama request: 404 Client Error: Not Found for url: http://localhost:11434/api/generate
    INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:49] "POST /api/chat HTTP/1.1" 200 -

I am able to curl http://localhost:11434 but not able to ping http://localhost:11434/api

curl http://localhost:11434
Ollama is running

What is the issue here? how to resolve this error.

OS

Windows

GPU

Intel

CPU

Intel

Ollama version

llama3.2:latest

Originally created by @kiran-kumar-akula on GitHub (Nov 15, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7689 ### What is the issue? While trying to run llama model I am getting Error: 404 Client Error: Not Found for url: http://localhost:11434/api/generate. I am running this in my windows 11 system with python 3.13.0 version I have installed llama3.2:latest and it's running. Code: response = requests.post('http://localhost:11434/api/generate', json={ "model": "llama3.2:latest", "prompt": f"{system_prompt}\n\n{prompt}", "stream": False }) Error Output: Ollama service is running! * Serving Flask app 'app' * Debug mode: on INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://127.0.0.1:3000 INFO:werkzeug:Press CTRL+C to quit INFO:werkzeug: * Restarting with stat Checking Ollama service... Ollama service is running! WARNING:werkzeug: * Debugger is active! INFO:werkzeug: * Debugger PIN: 119-213-946 INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:53] "GET / HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:53] "GET /api/history HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:53] "GET /favicon.ico HTTP/1.1" 404 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:55] "GET /api/health HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:08:55] "GET /api/history HTTP/1.1" 200 - ERROR:__main__:Error in Ollama request: 404 Client Error: Not Found for url: http://localhost:11434/api/generate INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:09:01] "POST /api/chat HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:37] "GET / HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:38] "GET /api/history HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:40] "GET /api/health HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:40] "GET /api/history HTTP/1.1" 200 - ERROR:__main__:Error in Ollama request: 404 Client Error: Not Found for url: http://localhost:11434/api/generate INFO:werkzeug:127.0.0.1 - - [15/Nov/2024 23:22:49] "POST /api/chat HTTP/1.1" 200 - I am able to curl http://localhost:11434 but not able to ping http://localhost:11434/api curl http://localhost:11434 Ollama is running What is the issue here? how to resolve this error. ### OS Windows ### GPU Intel ### CPU Intel ### Ollama version llama3.2:latest
GiteaMirror added the bug label 2026-05-04 09:05:03 -05:00
Author
Owner

@rick-github commented on GitHub (Nov 15, 2024):

What does the following return

curl -D - http://localhost:11434/api/generate -d "{\"model\":\"llama3.2:latest\",\"prompt\":\"hi\",\"stream\":false}"
<!-- gh-comment-id:2479649507 --> @rick-github commented on GitHub (Nov 15, 2024): What does the following return ```sh curl -D - http://localhost:11434/api/generate -d "{\"model\":\"llama3.2:latest\",\"prompt\":\"hi\",\"stream\":false}" ```
Author
Owner

@kiran-kumar-akula commented on GitHub (Nov 15, 2024):

@rick-github

C:\Users: curl -D - http://localhost:11434/api/generate
HTTP/1.1 404 Not Found
Content-Type: text/plain
Date: Fri, 15 Nov 2024 18:16:56 GMT
Content-Length: 18

404 page not found

C:\Users>curl -D - http://localhost:11434/api/generate -d "{"model":"llama3.2:latest","prompt":"hi","stream":false}"
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Fri, 15 Nov 2024 18:17:37 GMT
Content-Length: 470

{"model":"llama3.2:latest","created_at":"2024-11-15T18:17:37.8303989Z","response":"How can I assist you today?","done":true,"done_reason":"stop","context":[128006,9125,128007,271,38766,1303,33025,2696,25,6790,220,2366,18,271,128009,128006,882,128007,271,6151,128009,128006,78191,128007,271,4438,649,358,7945,499,3432,30],"total_duration":986768100,"load_duration":24535700,"prompt_eval_count":26,"prompt_eval_duration":373000000,"eval_count":8,"eval_duration":587000000}

<!-- gh-comment-id:2479662959 --> @kiran-kumar-akula commented on GitHub (Nov 15, 2024): @rick-github C:\Users: curl -D - http://localhost:11434/api/generate HTTP/1.1 404 Not Found Content-Type: text/plain Date: Fri, 15 Nov 2024 18:16:56 GMT Content-Length: 18 404 page not found C:\Users>curl -D - http://localhost:11434/api/generate -d "{\"model\":\"llama3.2:latest\",\"prompt\":\"hi\",\"stream\":false}" HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Date: Fri, 15 Nov 2024 18:17:37 GMT Content-Length: 470 {"model":"llama3.2:latest","created_at":"2024-11-15T18:17:37.8303989Z","response":"How can I assist you today?","done":true,"done_reason":"stop","context":[128006,9125,128007,271,38766,1303,33025,2696,25,6790,220,2366,18,271,128009,128006,882,128007,271,6151,128009,128006,78191,128007,271,4438,649,358,7945,499,3432,30],"total_duration":986768100,"load_duration":24535700,"prompt_eval_count":26,"prompt_eval_duration":373000000,"eval_count":8,"eval_duration":587000000}
Author
Owner

@rick-github commented on GitHub (Nov 15, 2024):

ollama is working fine, something is wrong with your app or the environment your app is running in. Are you using docker? What do the ollama server logs show?

<!-- gh-comment-id:2479678284 --> @rick-github commented on GitHub (Nov 15, 2024): ollama is working fine, something is wrong with your app or the environment your app is running in. Are you using docker? What do the ollama [server logs](https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#how-to-troubleshoot-issues) show?
Author
Owner

@rick-github commented on GitHub (Nov 15, 2024):

Copied your code into a file:

import requests

system_prompt = "You are an AI assistant"
prompt = "hi"

response = requests.post('http://localhost:11434/api/generate',
json={
"model": "llama3.2:latest",
"prompt": f"{system_prompt}\n\n{prompt}",
"stream": False
})

print(response.text)

Runs fine:

$ python 7689.py
{"model":"llama3.2:latest","created_at":"2024-11-15T18:36:48.900706688Z","response":"Hello! It's nice to meet you. I'm here to help answer any questions, provide information, or just chat with you. How can I assist you today?","done":true,"done_reason":"stop","context":[128006,9125,128007,271,38766,1303,33025,2696,25,6790,220,2366,18,271,128009,128006,882,128007,271,2675,527,459,15592,18328,271,6151,128009,128006,78191,128007,271,9906,0,1102,596,6555,311,3449,499,13,358,2846,1618,311,1520,4320,904,4860,11,3493,2038,11,477,1120,6369,449,499,13,2650,649,358,7945,499,3432,30],"total_duration":1773598547,"load_duration":16260172,"prompt_eval_count":32,"prompt_eval_duration":51000000,"eval_count":35,"eval_duration":1704000000}
<!-- gh-comment-id:2479701123 --> @rick-github commented on GitHub (Nov 15, 2024): Copied your code into a file: ```python import requests system_prompt = "You are an AI assistant" prompt = "hi" response = requests.post('http://localhost:11434/api/generate', json={ "model": "llama3.2:latest", "prompt": f"{system_prompt}\n\n{prompt}", "stream": False }) print(response.text) ``` Runs fine: ```console $ python 7689.py {"model":"llama3.2:latest","created_at":"2024-11-15T18:36:48.900706688Z","response":"Hello! It's nice to meet you. I'm here to help answer any questions, provide information, or just chat with you. How can I assist you today?","done":true,"done_reason":"stop","context":[128006,9125,128007,271,38766,1303,33025,2696,25,6790,220,2366,18,271,128009,128006,882,128007,271,2675,527,459,15592,18328,271,6151,128009,128006,78191,128007,271,9906,0,1102,596,6555,311,3449,499,13,358,2846,1618,311,1520,4320,904,4860,11,3493,2038,11,477,1120,6369,449,499,13,2650,649,358,7945,499,3432,30],"total_duration":1773598547,"load_duration":16260172,"prompt_eval_count":32,"prompt_eval_duration":51000000,"eval_count":35,"eval_duration":1704000000} ```
Author
Owner

@kiran-kumar-akula commented on GitHub (Nov 15, 2024):

@rick-github yeah I can see it is working in this way , But I am using this api to generate text to sql with flask web api, there I am getting 404 error.

image

So far I thought I am not able to connect to /api/generate but it is connecting. Will debug the whole code and get back to you.

I appreciate your quick assistance.

<!-- gh-comment-id:2479807385 --> @kiran-kumar-akula commented on GitHub (Nov 15, 2024): @rick-github yeah I can see it is working in this way , But I am using this api to generate text to sql with flask web api, there I am getting 404 error. ![image](https://github.com/user-attachments/assets/f2d61ffc-92fe-438c-8f73-dfc74f861e27) So far I thought I am not able to connect to /api/generate but it is connecting. Will debug the whole code and get back to you. I appreciate your quick assistance.
Author
Owner

@pdevine commented on GitHub (Nov 16, 2024):

GET /api/generate isn't a valid endpoint, which is why it's returning the 404. Arguably it could return a 405 NoMethod instead of a 404.

The endpoint you're looking for is POST /api/generate. With curl the -d option it is implicitly changing the request to a POST, but you can call it with curl -X POST /api/generate (which will of course generate a 400 error since it doesn't have a message body).

I'll go ahead and close the issue.

<!-- gh-comment-id:2480199528 --> @pdevine commented on GitHub (Nov 16, 2024): `GET /api/generate` isn't a valid endpoint, which is why it's returning the 404. Arguably it could return a 405 NoMethod instead of a 404. The endpoint you're looking for is `POST /api/generate`. With curl the `-d` option it is implicitly changing the request to a POST, but you can call it with `curl -X POST /api/generate` (which will of course generate a 400 error since it doesn't have a message body). I'll go ahead and close the issue.
Author
Owner

@eslynunez commented on GitHub (Nov 18, 2024):

@pdevine running into this issue as well. @kiran-kumar-akula seems to be referencing the POST method in their notes NOT the GET method. Could this be reopened?

<!-- gh-comment-id:2484377920 --> @eslynunez commented on GitHub (Nov 18, 2024): @pdevine running into this issue as well. @kiran-kumar-akula seems to be referencing the POST method in their notes NOT the GET method. Could this be reopened?
Author
Owner

@rick-github commented on GitHub (Nov 18, 2024):

What does the following return

curl -D - http://localhost:11434/api/generate -d "{\"model\":\"llama3.2:latest\",\"prompt\":\"hi\",\"stream\":false}"

What do your server logs show? Do you have a script that demonstrates the problem?

<!-- gh-comment-id:2484384153 --> @rick-github commented on GitHub (Nov 18, 2024): What does the following return ```sh curl -D - http://localhost:11434/api/generate -d "{\"model\":\"llama3.2:latest\",\"prompt\":\"hi\",\"stream\":false}" ``` What do your [server logs](https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#how-to-troubleshoot-issues) show? Do you have a script that demonstrates the problem?
Author
Owner

@pdevine commented on GitHub (Nov 19, 2024):

@eslynunez This was the command referenced:

curl -D - http://localhost:11434/api/generate

That will call GET /api/generate which will return a 404. Here's what happens if you add -X POST to that same call:

% curl -D - http://localhost:11434/api/generate -X POST
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Date: Tue, 19 Nov 2024 00:14:39 GMT
Content-Length: 32

{"error":"missing request body"}%

which is the expected output.

<!-- gh-comment-id:2484440685 --> @pdevine commented on GitHub (Nov 19, 2024): @eslynunez This was the command referenced: ``` curl -D - http://localhost:11434/api/generate ``` That will call `GET /api/generate` which will return a 404. Here's what happens if you add `-X POST` to that same call: ``` % curl -D - http://localhost:11434/api/generate -X POST HTTP/1.1 400 Bad Request Content-Type: application/json; charset=utf-8 Date: Tue, 19 Nov 2024 00:14:39 GMT Content-Length: 32 {"error":"missing request body"}% ``` which is the expected output.
Author
Owner

@eslynunez commented on GitHub (Dec 12, 2024):

I missed that you are correct thank you, @pdevine

<!-- gh-comment-id:2539542079 --> @eslynunez commented on GitHub (Dec 12, 2024): I missed that you are correct thank you, @pdevine
Author
Owner

@pdevine commented on GitHub (Dec 12, 2024):

I think we should probably return a 405 Method Not Allowed error just to be more succinct.

<!-- gh-comment-id:2540178052 --> @pdevine commented on GitHub (Dec 12, 2024): I think we should probably return a 405 Method Not Allowed error just to be more succinct.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#66966