Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ollama node “keep alive” setting has no effect on local n8n install #13655

Closed
miabe3003 opened this issue Mar 3, 2025 · 5 comments
Closed
Labels
in linear Issue or PR has been created in Linear for internal review Needs Feedback Waiting for further input or clarification.

Comments

@miabe3003
Copy link

Bug Description

Describe the problem/error/question

I have n8n running locally on my raspi and using it with Ollama. All works fine except that I run easily in a timeout situation with longer prompts as the ollama (chat) model node throws an error after exactly 5 minutes.
I suspect that that the default “keep alive” setting causes this problem, but setting it to 50m oder -1m does not have any effect.

What is the error message (if any)?
{
"errorMessage": "fetch failed",
"errorDetails": {},
"n8nDetails": {
"time": "26.2.2025, 20:40:04",
"n8nVersion": "1.78.1 (Self Hosted)",
"binaryDataMode": "default",
"cause": {}
}
}

Image

Share the output returned by the last node
{
"errorMessage": "fetch failed",
"errorDetails": {},
"n8nDetails": {
"time": "26.2.2025, 20:40:04",
"n8nVersion": "1.78.1 (Self Hosted)",
"binaryDataMode": "default",
"cause": {}
}
}

I noticed this default timeout and tried to override it with this “keep alive” setting in the Ollama Chat Model Node:

Image

I tried to use a negative number as well to disable it, but no effect.

Unfortunately the node always stops after the default 5 minutes:

Image

Updated to n8n 1.80.3 but still same results.

To Reproduce

  1. create LLM Chain and Ollama Chat Model nodes
  2. set keep alive from 5 minutes to 10 minutes
  3. make a request that takes longer than 5 minutes
  4. ollama will stop exactly after 5 minutes

Expected behavior

shoud respect the time value entered in the keep alive setting.
(Ollama works fine when I access it via the Open WebUI app.)

Operating System

Linux Debian 6.6.51

n8n Version

1.80.3

Node.js Version

don't know, running on UmbrelOS 1.3

Database

SQLite (default)

Execution mode

main (default)

@Joffcom
Copy link
Member

Joffcom commented Mar 3, 2025

Hey @miabe3003,

We have created an internal ticket to look into this which we will be tracking as "GHC-1037"

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Mar 3, 2025
@Joffcom
Copy link
Member

Joffcom commented Mar 4, 2025

Hey @miabe3003,

From what I can see the keep alive is not linked to how long we should wait for a response but instead it is how long ollama should keep the model in memory after being called.

https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately

@Joffcom Joffcom added the Needs Feedback Waiting for further input or clarification. label Mar 4, 2025
@miabe3003
Copy link
Author

Hi @Joffcom ,

thanks for the feedback!

Yes it looks like it unloads the model from ollama after 5 minutes which causes the error. If I could keep it alive for lets say 30 minutes it would be sufficient to solve my request, but it looks like the keep alive setting is not passed to ollama. No matter what I entered there, after 300.000ms the error "fetch failed" is shown as the model is not longer available I guess.

@Joffcom Joffcom removed the Needs Feedback Waiting for further input or clarification. label Mar 4, 2025
@Joffcom
Copy link
Member

Joffcom commented Mar 4, 2025

Hey @miabe3003,

I have done a quick test and we do send keep_alive to Ollama, Below is an example of what we send which looks to be correct.

{
  "model": "llama3.2",
  "keep_alive": "50m",
  "options": {},
  "messages": [
    {
      "role": "user",
      "content": "test"
    }
  ],
  "stream": true
}

Could there be an issue with ollama, I have taken a quick look and there are a few issues open around keep_alive not appearing to work and dropping from memory.

@Joffcom Joffcom added the Needs Feedback Waiting for further input or clarification. label Mar 4, 2025
@miabe3003
Copy link
Author

Hi @Joffcom ,

thanks for testing the keep_alive function and you are right, the keep_alive is not the problem.
I did some more testing while monitoring the memory load and it is not the unloading the model that couses the "fetch failed" error after 300.000ms. So it must be some other timeout related setting but I could not find it yet.
But as the access via openWebUI to the same ollama instance does not have the problem, I guess the problem is somewhere to be found in the n8n nodes.

I am closing this ticket and will investigate further using the HTTP request. Will open a new ticket if I pin the issue down...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review Needs Feedback Waiting for further input or clarification.
Projects
None yet
Development

No branches or pull requests

2 participants