[GH-ISSUE #2736] Windows version "/api/generate" 404 not found #48159

Closed
opened 2026-04-28 06:55:34 -05:00 by GiteaMirror · 33 comments
Owner

Originally created by @t41372 on GitHub (Feb 24, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2736

截圖 2024-02-24 下午2 48 29 截圖 2024-02-24 下午2 54 17

The "/api/generate" is not functioning and display 404 on the Windows version (not WSL), despite the Ollama server running and "/" being accessible. The same code works on the Ollama server on my Mac, so I guess the issue is not with my code.

Originally created by @t41372 on GitHub (Feb 24, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2736 <img width="1310" alt="截圖 2024-02-24 下午2 48 29" src="https://github.com/ollama/ollama/assets/36402030/8d1aac17-75f5-4a5c-8f27-a6569db7256c"> <img width="431" alt="截圖 2024-02-24 下午2 54 17" src="https://github.com/ollama/ollama/assets/36402030/99030d6f-9393-4eb5-b617-e04c369fdefe"> The "/api/generate" is not functioning and display 404 on the Windows version (not WSL), despite the Ollama server running and "/" being accessible. The same code works on the Ollama server on my Mac, so I guess the issue is not with my code.
Author
Owner

@xrb12250 commented on GitHub (Feb 25, 2024):

Same happens to me on macOS after several generations... /api/generate ist dead despite the app and server is running... Before it stopped, the GPU load was gradually decreasing and then suddenly drops to 0.

<!-- gh-comment-id:1962761978 --> @xrb12250 commented on GitHub (Feb 25, 2024): Same happens to me on macOS after several generations... /api/generate ist dead despite the app and server is running... Before it stopped, the GPU load was gradually decreasing and then suddenly drops to 0.
Author
Owner

@jmorganca commented on GitHub (Feb 25, 2024):

Hi there, 404 can be returned with POST /api/generate when the model doesn't exist. Would it be possible to first ollama pull <model> to make sure it's available locally?

@xrb12250 sorry about this - would it be possible to share the prompt and model you're using (and if so – would it be possible to open a separate GitHub issue?). Thanks so much - will make sure to look at this.

<!-- gh-comment-id:1962810574 --> @jmorganca commented on GitHub (Feb 25, 2024): Hi there, 404 can be returned with `POST /api/generate` when the model doesn't exist. Would it be possible to first `ollama pull <model>` to make sure it's available locally? @xrb12250 sorry about this - would it be possible to share the prompt and model you're using (and if so – would it be possible to open a separate GitHub issue?). Thanks so much - will make sure to look at this.
Author
Owner

@t41372 commented on GitHub (Feb 25, 2024):

I can confirm that the model is available locally.

<!-- gh-comment-id:1962840001 --> @t41372 commented on GitHub (Feb 25, 2024): I can confirm that the model is available locally.
Author
Owner

@jmorganca commented on GitHub (Feb 25, 2024):

@t41372 thanks! Does running this powershell script work for you? Make sure to have llama2

(Invoke-WebRequest -method POST -Body '{"model":"llama2", "prompt":"Why is the sky blue?", "stream": false}' -uri http://localhost:11434/api/generate ).Content | ConvertFrom-json
<!-- gh-comment-id:1962848427 --> @jmorganca commented on GitHub (Feb 25, 2024): @t41372 thanks! Does running this powershell script work for you? Make sure to have `llama2` ``` (Invoke-WebRequest -method POST -Body '{"model":"llama2", "prompt":"Why is the sky blue?", "stream": false}' -uri http://localhost:11434/api/generate ).Content | ConvertFrom-json ```
Author
Owner

@t41372 commented on GitHub (Feb 25, 2024):

截圖 2024-02-25 上午2 15 36 截圖 2024-02-25 上午2 14 39

It doesn't seem to work. Here are the app.log and server.log if these would help.

app.log
server.log

<!-- gh-comment-id:1962868331 --> @t41372 commented on GitHub (Feb 25, 2024): <img width="1096" alt="截圖 2024-02-25 上午2 15 36" src="https://github.com/ollama/ollama/assets/36402030/5577c9ce-dc04-4aa0-892e-17ea878c5b8e"> <img width="886" alt="截圖 2024-02-25 上午2 14 39" src="https://github.com/ollama/ollama/assets/36402030/d7462094-888e-4d2f-80e8-72b7edbb68a8"> It doesn't seem to work. Here are the app.log and server.log if these would help. [app.log](https://github.com/ollama/ollama/files/14395857/app.log) [server.log](https://github.com/ollama/ollama/files/14395858/server.log)
Author
Owner

@lavahasif commented on GitHub (Feb 25, 2024):

Invoke-RestMethod -Uri 'http://localhost:11434/api/generate' -Method Post -Headers @{ 'Content-Type' = 'application/json' } -Body '{"model":"gemma:latest", "prompt":"create a codeigniter form", "stream": false}

Replace gemma:latest with your model like llama2 or mistral

Or

Run this in postman

curl --location 'http://localhost:11434/api/generate' \
--header 'Content-Type: text/plain' \
--data '{"model":"gemma:latest", "prompt":"create a codeigniter form", "stream": false}
'
<!-- gh-comment-id:1962940891 --> @lavahasif commented on GitHub (Feb 25, 2024): `Invoke-RestMethod -Uri 'http://localhost:11434/api/generate' -Method Post -Headers @{ 'Content-Type' = 'application/json' } -Body '{"model":"gemma:latest", "prompt":"create a codeigniter form", "stream": false}` Replace gemma:latest with your model like llama2 or mistral Or Run this in postman ``` curl --location 'http://localhost:11434/api/generate' \ --header 'Content-Type: text/plain' \ --data '{"model":"gemma:latest", "prompt":"create a codeigniter form", "stream": false} ' ```
Author
Owner

@ericrval commented on GitHub (Mar 7, 2024):

On your application, try to change de stream value to False.

<!-- gh-comment-id:1984548255 --> @ericrval commented on GitHub (Mar 7, 2024): On your application, try to change de stream value to False.
Author
Owner

@andrewnguonly commented on GitHub (Mar 10, 2024):

This issue may also be happening on WSL2 (Ubuntu 22.04.3 LTS) on Windows: https://github.com/andrewnguonly/Lumos/issues/126

<!-- gh-comment-id:1987264579 --> @andrewnguonly commented on GitHub (Mar 10, 2024): This issue may also be happening on WSL2 (Ubuntu 22.04.3 LTS) on Windows: https://github.com/andrewnguonly/Lumos/issues/126
Author
Owner

@andrewnguonly commented on GitHub (Mar 11, 2024):

This issue may also be happening on WSL2 (Ubuntu 22.04.3 LTS) on Windows: andrewnguonly/Lumos#126

False alarm. We did not reproduce this issue.

<!-- gh-comment-id:1987419787 --> @andrewnguonly commented on GitHub (Mar 11, 2024): > This issue may also be happening on WSL2 (Ubuntu 22.04.3 LTS) on Windows: [andrewnguonly/Lumos#126](https://github.com/andrewnguonly/Lumos/issues/126) False alarm. We did not reproduce this issue.
Author
Owner

@jmorganca commented on GitHub (Mar 12, 2024):

Hi there, it seems like the model might not be available locally – you can run ollama pull <model> to make sure it's available. Will close this for now but feel free to re-open it

<!-- gh-comment-id:1990317248 --> @jmorganca commented on GitHub (Mar 12, 2024): Hi there, it seems like the model might not be available locally – you can run `ollama pull <model>` to make sure it's available. Will close this for now but feel free to re-open it
Author
Owner

@WiseMarius commented on GitHub (Mar 12, 2024):

Hi, I have the same issue on windows.
image
image
image

<!-- gh-comment-id:1990947578 --> @WiseMarius commented on GitHub (Mar 12, 2024): Hi, I have the same issue on windows. ![image](https://github.com/ollama/ollama/assets/25198837/b4baa85e-0bde-449c-a9ac-b10d3354581d) ![image](https://github.com/ollama/ollama/assets/25198837/643fa9d2-c9a5-4395-b26d-6ef49ef5bdef) ![image](https://github.com/ollama/ollama/assets/25198837/30535251-3f80-4dd2-95e8-45893f0ce92b)
Author
Owner

@daudrain commented on GitHub (Mar 16, 2024):

I got the same issue with Ubuntu 20.04 after running ollama run codellama:7b , /api/generate was returning 404.
Then I did a ollama pull codellama and /api/generate returns 200

<!-- gh-comment-id:2001920416 --> @daudrain commented on GitHub (Mar 16, 2024): I got the same issue with Ubuntu 20.04 after running `ollama run codellama:7b` , `/api/generate` was returning 404. Then I did a `ollama pull codellama` and `/api/generate` returns 200
Author
Owner

@alexdai039 commented on GitHub (Mar 17, 2024):

got the same issue with MacOS (Sonoma 14.4)...

<!-- gh-comment-id:2002471862 --> @alexdai039 commented on GitHub (Mar 17, 2024): got the same issue with MacOS (Sonoma 14.4)...
Author
Owner

@mxyng commented on GitHub (Mar 18, 2024):

Using a browser to reach /api/generate will not work because there is no GET /api/generate. Please use curl, postman, etc. which allows you to call POST /api/generate with JSON data

<!-- gh-comment-id:2003135746 --> @mxyng commented on GitHub (Mar 18, 2024): Using a browser to reach `/api/generate` will not work because there is no `GET /api/generate`. Please use curl, postman, etc. which allows you to call `POST /api/generate` with JSON data
Author
Owner

@PhPv commented on GitHub (Apr 5, 2024):

Hi. I ran into the same problem when I tried to walk through the quickstart from llamindex. Crashes with the error that the api endpoint/chat url was not found http://localhost:11434/api/chat it also says that 404 is not found. (on http://localhost:11434/ i see that "ollama is running".
What am I doing wrong?

<!-- gh-comment-id:2040214305 --> @PhPv commented on GitHub (Apr 5, 2024): Hi. I ran into the same problem when I tried to walk through the quickstart from [llamindex](https://docs.llamaindex.ai/en/stable/getting_started/starter_example_local/). Crashes with the error that the api endpoint/chat url was not found http://localhost:11434/api/chat it also says that 404 is not found. (on http://localhost:11434/ i see that "ollama is running". What am I doing wrong?
Author
Owner

@asma-faraji commented on GitHub (Apr 6, 2024):

I have the similiar issues as @PhPv . the api/generate return the response but I am getting 404 is not found for api/chat. How can I solve this issue?

<!-- gh-comment-id:2041164521 --> @asma-faraji commented on GitHub (Apr 6, 2024): I have the similiar issues as @PhPv . the api/generate return the response but I am getting 404 is not found for api/chat. How can I solve this issue?
Author
Owner

@PhPv commented on GitHub (Apr 9, 2024):

not actual :) thx

I'm trying to use Alama in different services:

  1. danswer - according to the guide you need to check the performance of ollamacurl http://localhost:11434/api/generate -d '{ "model": "llama2", "prompt": "Why is the sky blue?" }'- I get error 404. In docker i see this: Max retries exceeded with url: /api/chat (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fedac124890>: Failed to establish a new connection: [Errno 111] Connection refused'))
  2. lama index according to the guide I get the same 404 error
  3. I use openwebui and everything works
  4. I tried to run a POST request in powershell with InvokeWebRequest. It worked without errors and the model returned a response when querying the api/generate.
    What is the difference between 1, 2 and 3 applications? Why 1 and 2 don't work(
<!-- gh-comment-id:2044373445 --> @PhPv commented on GitHub (Apr 9, 2024): not actual :) thx I'm trying to use Alama in different services: 1. danswer - according to the [guide ](https://docs.danswer.dev/gen_ai_configs/ollama) you need to check the performance of ollama` curl http://localhost:11434/api/generate -d '{ "model": "llama2", "prompt": "Why is the sky blue?" }' `- I get error 404. In docker i see this: `Max retries exceeded with url: /api/chat (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fedac124890>: Failed to establish a new connection: [Errno 111] Connection refused'))` 3. lama index according to the [guide ](https://docs.llamaindex.ai/en/stable/getting_started/starter_example_local) I get the same 404 error 4. I use [openwebui ](https://docs.openwebui.com) and everything works 5. I tried to run a POST request in powershell with InvokeWebRequest. It worked without errors and the model returned a response when querying the api/generate. What is the difference between 1, 2 and 3 applications? Why 1 and 2 don't work(
Author
Owner

@BenBatsir commented on GitHub (Apr 25, 2024):

any update on this?

I'm getting:

[GIN] 2024/04/25 - 16:38:43 | 404 |     408.542µs |       127.0.0.1 | POST     "/api/chat"
<!-- gh-comment-id:2077293030 --> @BenBatsir commented on GitHub (Apr 25, 2024): any update on this? I'm getting: ``` [GIN] 2024/04/25 - 16:38:43 | 404 | 408.542µs | 127.0.0.1 | POST "/api/chat" ```
Author
Owner

@ysfscream commented on GitHub (Apr 26, 2024):

I encountered this issue until I changed my GET method to a POST method.

<!-- gh-comment-id:2079793983 --> @ysfscream commented on GitHub (Apr 26, 2024): I encountered this issue until I changed my GET method to a POST method.
Author
Owner

@MustCodeAl commented on GitHub (Apr 29, 2024):

getting same issue on m1 mac Sonoma 14.4

<!-- gh-comment-id:2081782481 --> @MustCodeAl commented on GitHub (Apr 29, 2024): getting same issue on m1 mac Sonoma 14.4
Author
Owner

@trybonk commented on GitHub (May 22, 2024):

This command helped me solve the 404 error problem
Win11 ollama v0.1.38

ollama pull name_model

<!-- gh-comment-id:2125613431 --> @trybonk commented on GitHub (May 22, 2024): This command helped me solve the 404 error problem Win11 ollama v0.1.38 > ollama pull name_model
Author
Owner

@gustavoarchuby71 commented on GitHub (May 24, 2024):

Ubuntu 22.04, ollama, openweb_ui running perfectly, queries with curl work without problem but when I query from llama-index, it gives me this error:
httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://localhost:11434 /api/chat'.

I think the problem has to do with extra parameters that need to be entered, the same ones that happened to curl, method(post or get), Embeddings, etc.
But i don´t konow how resolve this.

<!-- gh-comment-id:2130077013 --> @gustavoarchuby71 commented on GitHub (May 24, 2024): Ubuntu 22.04, ollama, openweb_ui running perfectly, queries with curl work without problem but when I query from llama-index, it gives me this error: httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://localhost:11434 /api/chat'. I think the problem has to do with extra parameters that need to be entered, the same ones that happened to curl, method(post or get), Embeddings, etc. But i don´t konow how resolve this.
Author
Owner

@Satyam7166-tech commented on GitHub (May 25, 2024):

Hey I have Macos Sonoma 14.5 and I got the same issue.

I tried using Ollama with Llamaindex.

The strange thing is "./ollama run phi3:latest" works absolutely fine in the terminal but response = query_engine.query("hello") in llamaindex doesn't where it shows [GIN] 2024/05/25 - 15:18:34 | 200 | 19.810265083s | 127.0.0.1 | POST "/api/generate" in the ./ollama serve terminal tab

I can confirm that the same code worked in Macos Ventura.

<!-- gh-comment-id:2131169887 --> @Satyam7166-tech commented on GitHub (May 25, 2024): Hey I have Macos Sonoma 14.5 and I got the same issue. I tried using Ollama with Llamaindex. The strange thing is "./ollama run phi3:latest" works absolutely fine in the terminal but `response = query_engine.query("hello")` in llamaindex doesn't where it shows `[GIN] 2024/05/25 - 15:18:34 | 200 | 19.810265083s | 127.0.0.1 | POST "/api/generate"` in the ./ollama serve terminal tab I can confirm that the same code worked in Macos Ventura.
Author
Owner

@gustavoarchuby71 commented on GitHub (May 25, 2024):

New enviroment, new libraries all work.

Thanks

<!-- gh-comment-id:2131313062 --> @gustavoarchuby71 commented on GitHub (May 25, 2024): New enviroment, new libraries all work. Thanks
Author
Owner

@strongbugman commented on GitHub (May 31, 2024):

check your ollama_api_base in config/setting and make sure there is no / after hostname like http://localhost:11434/, this maybe wrong because the finnal api url may become http://localhost:11434//api/generate(double slash!) which will return 404 always:

❯ curl --location 'http://localhost:11434//api/generate' \
--header 'Content-Type: text/json' \
--data '{"model":"codegemma:latest", "prompt":"say hi to me", "stream": false}
'

404 page not found
<!-- gh-comment-id:2141378756 --> @strongbugman commented on GitHub (May 31, 2024): check your `ollama_api_base` in config/setting and make sure there is no `/` after hostname like `http://localhost:11434/`, this maybe wrong because the finnal api url may become `http://localhost:11434//api/generate`(double slash!) which will return 404 always: ``` ❯ curl --location 'http://localhost:11434//api/generate' \ --header 'Content-Type: text/json' \ --data '{"model":"codegemma:latest", "prompt":"say hi to me", "stream": false} ' 404 page not found ```
Author
Owner

@AlmaAROM commented on GitHub (Jun 23, 2024):

Hi there!
I'm trying to learn how to connect ollama with crewai or Praison, but it seems is not working at my end. I don't understand how to set up the port. This is what I'm putting inside the console curl http://localhost:11434/api/generate -d '{"model": "openhermes"}'

the error display is below

curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
curl: (3) unmatched close brace/bracket in URL position 11:
openhermes}'

I'm using windows 10... Let me know

<!-- gh-comment-id:2184820864 --> @AlmaAROM commented on GitHub (Jun 23, 2024): Hi there! I'm trying to learn how to connect ollama with crewai or Praison, but it seems is not working at my end. I don't understand how to set up the port. This is what I'm putting inside the console `curl http://localhost:11434/api/generate -d '{"model": "openhermes"}'` the error display is below curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535 curl: (3) unmatched close brace/bracket in URL position 11: openhermes}' I'm using windows 10... Let me know
Author
Owner

@yurochang commented on GitHub (Jul 22, 2024):

same problem make graphrag broken for me:
image

<!-- gh-comment-id:2241888953 --> @yurochang commented on GitHub (Jul 22, 2024): same problem make graphrag broken for me: ![image](https://github.com/user-attachments/assets/83fa2108-b193-4556-84b0-63db2ecf0922)
Author
Owner

@smrinalsingh commented on GitHub (Aug 18, 2024):

I encountered this issue until I changed my GET method to a POST method.

Exactly. I tried reproducing this issue using python and seems like the requests sent as GET return 404. Changing it to POST did the job.

<!-- gh-comment-id:2295327902 --> @smrinalsingh commented on GitHub (Aug 18, 2024): > I encountered this issue until I changed my GET method to a POST method. Exactly. I tried reproducing this issue using python and seems like the requests sent as GET return 404. Changing it to POST did the job.
Author
Owner

@vitustockholm commented on GitHub (Oct 14, 2024):

Modellife could not exist try to check first :
ollama list if its empty, - thats the reason and follow with ,, ollama pull modelname modelname mistral, llama2 etc. Then it should work, check modelife innstead of base url , because localhost or 127,0,0 should work both if 0,0,0 was whitelisted in envariables

<!-- gh-comment-id:2410000843 --> @vitustockholm commented on GitHub (Oct 14, 2024): Modellife could not exist try to check first : `` ollama list `` if its empty, - thats the reason and follow with ,, ``ollama pull modelname`` modelname mistral, llama2 etc. Then it should work, check modelife innstead of base url , because localhost or 127,0,0 should work both if 0,0,0 was whitelisted in envariables
Author
Owner

@smowtion commented on GitHub (Oct 25, 2024):

try other 127.0.0.1:11434 or 0.0.0.0:11434
...

<!-- gh-comment-id:2436889069 --> @smowtion commented on GitHub (Oct 25, 2024): try other 127.0.0.1:11434 or 0.0.0.0:11434 ...
Author
Owner

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

Does ollama ps list the model?
If not try ollama run <modelname>

<!-- gh-comment-id:2480469770 --> @vimalamaldas commented on GitHub (Nov 16, 2024): Does ` ollama ps` list the model? If not try `ollama run <modelname>`
Author
Owner

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

I met the same problem while trying to connect ollama with the VS code extension 'Continue' and it's solved as follow:

  1. run ollama ps to make sure the exact model name you are attempt to connect.
  2. make sure you have the right model name in you configure, for example your 'Continue' configure file.
<!-- gh-comment-id:2485169672 --> @alvendarthy commented on GitHub (Nov 19, 2024): I met the same problem while trying to connect ollama with the VS code extension 'Continue' and it's solved as follow: 1. run `ollama ps` to make sure the exact model name you are attempt to connect. 2. make sure you have the right model name in you configure, for example your 'Continue' configure file.
Author
Owner

@thrishank007 commented on GitHub (Jan 8, 2025):

use postman or insomnia with POST request, it will work. and make sure you pull model and check if it's there in ollama list
url: http://localhost:11434/api/generate
data (json): { "model": "qwen2.5-coder:3b", "prompt": "Why is the sky blue?", "stream": false }
method: POST
image

<!-- gh-comment-id:2577592830 --> @thrishank007 commented on GitHub (Jan 8, 2025): use postman or insomnia with POST request, it will work. and make sure you pull model and check if it's there in `ollama list` url: `http://localhost:11434/api/generate` data (json): `{ "model": "qwen2.5-coder:3b", "prompt": "Why is the sky blue?", "stream": false }` method: `POST` ![image](https://github.com/user-attachments/assets/3e86ebbd-a23e-401a-a3c4-9f5933b25e13)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#48159