[GH-ISSUE #7578] Embedding fails with Server error httpx.HTTPStatusError: 500 Internal Server Error in version 0.4.0 #51342

Closed
opened 2026-04-28 19:35:50 -05:00 by GiteaMirror · 19 comments
Owner

Originally created by @frtendero on GitHub (Nov 8, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7578

What is the issue?

Server log: server.log

After upgrading from version 0.3.12 to version 0.4.0, embedding calculation fails when multiple documents are fed. It can handle small quantities but fails midway with larger lists, throwing httpx.HTTPStatusError: 500 Internal Server Error. Since it looked like a timeout, I tried increasing the timeout parameter with no luck. I'm interacting with ollama through the python client.

I tried downgrading back to ollama 0.3.12 and the embedding worked again.

Part of the error trace:

Calculating embeddings:  48%|█████████████████████████████████████████████████████████████▏                                                                 | 81/168 [00:14<00:15,  5.66it/s]

ollama._types.ResponseError: failed to generate embedding

[...]

Stack Trace:
File "<path_to_env>/ollama/_client.py", line 281, in embeddings
    return self._request(
           ^^^^^^^^^^^^^^
  File "<path_to_env>/ollama/_client.py", line 75, in _request
    raise ResponseError(e.response.text, e.response.status_code) from None

The above exception occurred during handling of the following exception:
httpx.HTTPStatusError: Server error '500 Internal Server Error' for url '<server_url>/api/embeddings'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

Stack Trace:
  File "<path_to_env>/ollama/_client.py", line 73, in _request
    response.raise_for_status()
  File "<path_to_env>/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)

Thanks :)

OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

0.4.0

Originally created by @frtendero on GitHub (Nov 8, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7578 ### What is the issue? **Server log:** [server.log](https://github.com/user-attachments/files/17682295/server.log) After upgrading from version 0.3.12 to version 0.4.0, embedding calculation fails when multiple documents are fed. It can handle small quantities but fails midway with larger lists, throwing `httpx.HTTPStatusError: 500 Internal Server Error`. Since it looked like a timeout, I tried increasing the timeout parameter with no luck. I'm interacting with ollama through the python client. I tried **downgrading back to ollama 0.3.12 and the embedding worked again**. Part of the error trace: ``` Calculating embeddings: 48%|█████████████████████████████████████████████████████████████▏ | 81/168 [00:14<00:15, 5.66it/s] ollama._types.ResponseError: failed to generate embedding [...] Stack Trace: File "<path_to_env>/ollama/_client.py", line 281, in embeddings return self._request( ^^^^^^^^^^^^^^ File "<path_to_env>/ollama/_client.py", line 75, in _request raise ResponseError(e.response.text, e.response.status_code) from None The above exception occurred during handling of the following exception: httpx.HTTPStatusError: Server error '500 Internal Server Error' for url '<server_url>/api/embeddings' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 Stack Trace: File "<path_to_env>/ollama/_client.py", line 73, in _request response.raise_for_status() File "<path_to_env>/httpx/_models.py", line 763, in raise_for_status raise HTTPStatusError(message, request=request, response=self) ``` Thanks :) ### OS Windows ### GPU Nvidia ### CPU Intel ### Ollama version 0.4.0
GiteaMirror added the needs more infobug labels 2026-04-28 19:35:50 -05:00
Author
Owner

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

Server logs will aid in debugging. If you could provide an example of a prompt that causes the 500 that would also be helpful.

<!-- gh-comment-id:2465319738 --> @rick-github commented on GitHub (Nov 8, 2024): [Server logs](https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#how-to-troubleshoot-issues) will aid in debugging. If you could provide an example of a prompt that causes the 500 that would also be helpful.
Author
Owner

@frtendero commented on GitHub (Nov 8, 2024):

Hi @rick-github, thanks for your quick response. Here is the server log server.log

I have removed the multiple lines of the POST to "/api/embeddings". In case there is not enough info, I will activate DEBUG mode and send again the log

Regarding the prompt, the fail is occurring when creating the embeddings using haystack's ollama document embedder. I tried multiple embedders: mxbai, nomic and snowflake. All working with ollama 0.3.12, but not with 0.4.0

<!-- gh-comment-id:2465441261 --> @frtendero commented on GitHub (Nov 8, 2024): Hi @rick-github, thanks for your quick response. Here is the server log [server.log](https://github.com/user-attachments/files/17682295/server.log) I have removed the multiple lines of the POST to "/api/embeddings". In case there is not enough info, I will activate DEBUG mode and send again the log Regarding the prompt, the fail is occurring when creating the embeddings using [haystack's ollama document embedder](https://docs.haystack.deepset.ai/docs/ollamadocumentembedder). I tried multiple embedders: mxbai, nomic and snowflake. All working with ollama 0.3.12, but not with 0.4.0
Author
Owner

@jessegross commented on GitHub (Nov 8, 2024):

@frtendero I'll see if I can reproduce but if you can send the the debug log that would be helpful.

<!-- gh-comment-id:2465653244 --> @jessegross commented on GitHub (Nov 8, 2024): @frtendero I'll see if I can reproduce but if you can send the the debug log that would be helpful.
Author
Owner

@igorschlum commented on GitHub (Nov 8, 2024):

@frtendero I could try also on an Mac. Could you try with some open source text files to embed and share the links (it could be ollama sources files).

<!-- gh-comment-id:2465663481 --> @igorschlum commented on GitHub (Nov 8, 2024): @frtendero I could try also on an Mac. Could you try with some open source text files to embed and share the links (it could be ollama sources files).
Author
Owner

@varyagnord commented on GitHub (Nov 11, 2024):

I encountered the same problem on Linux. Everything was working well with ollama 0.3.12, but not with 0.4.1.

<!-- gh-comment-id:2468986660 --> @varyagnord commented on GitHub (Nov 11, 2024): I encountered the same problem on Linux. Everything was working well with ollama 0.3.12, but not with 0.4.1.
Author
Owner

@varyagnord commented on GitHub (Nov 11, 2024):

If the string is short, for example, around 30 characters, embeddings are created normally, but if it's longer, this error occurs.

<!-- gh-comment-id:2468989209 --> @varyagnord commented on GitHub (Nov 11, 2024): If the string is short, for example, around 30 characters, embeddings are created normally, but if it's longer, this error occurs.
Author
Owner

@jessegross commented on GitHub (Nov 11, 2024):

@varyagnord Can you provide server logs with OLLAMA_DEBUG=1 set and also give a specific example that triggers it?

<!-- gh-comment-id:2469008752 --> @jessegross commented on GitHub (Nov 11, 2024): @varyagnord Can you provide server logs with OLLAMA_DEBUG=1 set and also give a specific example that triggers it?
Author
Owner

@wwjCMP commented on GitHub (Nov 12, 2024):

+1

time=2024-11-12T11:52:24.292+08:00 level=ERROR source=routes.go:453 msg="embedding generation failed" error="do embedding request: Post "http://127.0.0.1:51273/embedding": read tcp 127.0.0.1:51285->127.0.0.1:51273: wsarecv: An existing connection was forcibly closed by the remote host."
[GIN] 2024/11/12 - 11:52:24 | 500 | 1.7278147s | 127.0.0.1 | POST "/v1/embeddings"
Error #01: json: cannot unmarshal object into Go struct field StatusError.error of type string

<!-- gh-comment-id:2469539000 --> @wwjCMP commented on GitHub (Nov 12, 2024): +1 time=2024-11-12T11:52:24.292+08:00 level=ERROR source=routes.go:453 msg="embedding generation failed" error="do embedding request: Post \"http://127.0.0.1:51273/embedding\": read tcp 127.0.0.1:51285->127.0.0.1:51273: wsarecv: An existing connection was forcibly closed by the remote host." [GIN] 2024/11/12 - 11:52:24 | 500 | 1.7278147s | 127.0.0.1 | POST "/v1/embeddings" Error #01: json: cannot unmarshal object into Go struct field StatusError.error of type string
Author
Owner

@jessegross commented on GitHub (Nov 13, 2024):

@wwjCMP Similar to the comment above you, can you provide the full log with OLLAMA_DEBUG=1 and also give more specifics about how you triggered this?

<!-- gh-comment-id:2475048481 --> @jessegross commented on GitHub (Nov 13, 2024): @wwjCMP Similar to the comment above you, can you provide the full log with OLLAMA_DEBUG=1 and also give more specifics about how you triggered this?
Author
Owner

@jessegross commented on GitHub (Nov 14, 2024):

My best guess is that the errors are triggered by prompts that are only whitespace. If that happens, we will currently generate an error whereas past versions of Ollama were more tolerant.

If anyone who is running into this problem can test out this PR and let me know if that fixes it, that would be helpful to confirm:
https://github.com/ollama/ollama/pull/7659

<!-- gh-comment-id:2475137394 --> @jessegross commented on GitHub (Nov 14, 2024): My best guess is that the errors are triggered by prompts that are only whitespace. If that happens, we will currently generate an error whereas past versions of Ollama were more tolerant. If anyone who is running into this problem can test out this PR and let me know if that fixes it, that would be helpful to confirm: https://github.com/ollama/ollama/pull/7659
Author
Owner

@varyagnord commented on GitHub (Nov 14, 2024):

@varyagnord Can you provide server logs with OLLAMA_DEBUG=1 set and also give a specific example that triggers it?

I resolved my issue by reinstalling ollama. Now, version 0.4.1 is working fine for me. Thank you.

<!-- gh-comment-id:2477622266 --> @varyagnord commented on GitHub (Nov 14, 2024): > @varyagnord Can you provide server logs with OLLAMA_DEBUG=1 set and also give a specific example that triggers it? I resolved my issue by reinstalling ollama. Now, version 0.4.1 is working fine for me. Thank you.
Author
Owner

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

I also encountered the same problem #7288
Upgrading to version 0.4.4 did not resolve the issue.

<!-- gh-comment-id:2480368311 --> @viosay commented on GitHub (Nov 16, 2024): I also encountered the same problem #7288 Upgrading to version 0.4.4 did not resolve the issue.
Author
Owner

@frtendero commented on GitHub (Nov 26, 2024):

My best guess is that the errors are triggered by prompts that are only whitespace. If that happens, we will currently generate an error whereas past versions of Ollama were more tolerant.

If anyone who is running into this problem can test out this PR and let me know if that fixes it, that would be helpful to confirm: #7659

@jessegross It is working for me using version 0.4.3

<!-- gh-comment-id:2500270612 --> @frtendero commented on GitHub (Nov 26, 2024): > My best guess is that the errors are triggered by prompts that are only whitespace. If that happens, we will currently generate an error whereas past versions of Ollama were more tolerant. > > If anyone who is running into this problem can test out this PR and let me know if that fixes it, that would be helpful to confirm: #7659 @jessegross It is working for me using version 0.4.3
Author
Owner

@jessegross commented on GitHub (Nov 26, 2024):

Thanks a lot for testing and let me know.

<!-- gh-comment-id:2501745501 --> @jessegross commented on GitHub (Nov 26, 2024): Thanks a lot for testing and let me know.
Author
Owner

@igorschlum commented on GitHub (Nov 26, 2024):

@viosay and with version 0.4.5?

<!-- gh-comment-id:2501848268 --> @igorschlum commented on GitHub (Nov 26, 2024): @viosay and with version 0.4.5?
Author
Owner

@jessegross commented on GitHub (Nov 26, 2024):

The problem that @viosay ran into in #7288 looks different to me.

<!-- gh-comment-id:2501934180 --> @jessegross commented on GitHub (Nov 26, 2024): The problem that @viosay ran into in #7288 looks different to me.
Author
Owner

@viosay commented on GitHub (Nov 27, 2024):

@viosay and with version 0.4.5?

@igorschlum The issue persists but is not triggered by prompts that consist only of whitespace. This problem exists in all versions after 0.3.13.

<!-- gh-comment-id:2502372840 --> @viosay commented on GitHub (Nov 27, 2024): > @viosay and with version 0.4.5? @igorschlum The issue persists but is not triggered by prompts that consist only of whitespace. This problem exists in all versions after 0.3.13.
Author
Owner

@igorschlum commented on GitHub (Nov 27, 2024):

@viosay, are you referring to the size of embedding chunks as described in this issue: https://github.com/ollama/ollama/issues/7288 ?

<!-- gh-comment-id:2503233508 --> @igorschlum commented on GitHub (Nov 27, 2024): @viosay, are you referring to the size of embedding chunks as described in this issue: https://github.com/ollama/ollama/issues/7288 ?
Author
Owner

@viosay commented on GitHub (Nov 27, 2024):

@jessegross Yes, it seems to be caused by issues related to the embedding block size.

<!-- gh-comment-id:2503244114 --> @viosay commented on GitHub (Nov 27, 2024): @jessegross Yes, it seems to be caused by issues related to the embedding block size.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#51342