A "maximum recursion depth exceeded" issue occurred in the llm node, and the large model being called is locally deployed. #21982

Closed
opened 2026-02-21 20:15:09 -05:00 by yindo · 2 comments
Owner

Originally created by @Zz-lo on GitHub (Jan 29, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.9.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Image

✔️ Expected Behavior

Expected to output results normally.

Actual Behavior

No response

Originally created by @Zz-lo on GitHub (Jan 29, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce <img width="710" height="248" alt="Image" src="https://github.com/user-attachments/assets/a4ffe9cb-e6b8-4e8f-a0e7-bcf0eedce231" /> ### ✔️ Expected Behavior Expected to output results normally. ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 20:15:09 -05:00
yindo closed this issue 2026-02-21 20:15:09 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 29, 2026):

Hi @Zz-lo! I'm Dosu and I’m helping the dify team.

The "maximum recursion depth exceeded" error in Dify v1.9.1 with a locally deployed model is a known issue, most often caused by incompatibility between gevent 25.9.1 and Python 3.12's SSL module monkey patching. This triggers infinite recursion in SSLContext and can affect LLM nodes, especially in Docker deployments. The recommended fix is to downgrade gevent to 24.11.1 in your Docker environment. You can do this by adding the following to your Dockerfile:

FROM langgenius/dify-api:1.9.1
RUN pip install --no-cache-dir gevent==24.11.1

Make sure monkey patching is applied before any SSL or requests imports in your startup scripts to avoid similar issues.

If your workflow uses knowledge base retrieval or hybrid search, also check your top_k settings and avoid broad metadata filters or hybrid search with rerank on large datasets, as these can also cause recursion errors if too many documents are returned at once. Recent versions include deduplication fixes for this scenario, so upgrading Dify may help if you continue to see recursion errors even after the gevent change.

References:

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 29, 2026): <!-- Greeting --> Hi @Zz-lo! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> The "maximum recursion depth exceeded" error in Dify v1.9.1 with a locally deployed model is a known issue, most often caused by incompatibility between gevent 25.9.1 and Python 3.12's SSL module monkey patching. This triggers infinite recursion in SSLContext and can affect LLM nodes, especially in Docker deployments. The recommended fix is to downgrade gevent to 24.11.1 in your Docker environment. You can do this by adding the following to your Dockerfile: ```dockerfile FROM langgenius/dify-api:1.9.1 RUN pip install --no-cache-dir gevent==24.11.1 ``` Make sure monkey patching is applied before any SSL or requests imports in your startup scripts to avoid similar issues. If your workflow uses knowledge base retrieval or hybrid search, also check your `top_k` settings and avoid broad metadata filters or hybrid search with rerank on large datasets, as these can also cause recursion errors if too many documents are returned at once. Recent versions include deduplication fixes for this scenario, so upgrading Dify may help if you continue to see recursion errors even after the gevent change. References: - [gevent/Python 3.12 recursion error and fix](https://github.com/langgenius/dify/issues/26689) - [Knowledge base retrieval recursion error and mitigation](https://github.com/langgenius/dify/discussions/30446) - [Deduplication fix for hybrid search recursion](https://github.com/langgenius/dify/issues/28035) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/8a7b2a79-3667-4806-8f4b-d34a930eec5c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8a7b2a79-3667-4806-8f4b-d34a930eec5c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8a7b2a79-3667-4806-8f4b-d34a930eec5c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8a7b2a79-3667-4806-8f4b-d34a930eec5c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8a7b2a79-3667-4806-8f4b-d34a930eec5c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8a7b2a79-3667-4806-8f4b-d34a930eec5c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8a7b2a79-3667-4806-8f4b-d34a930eec5c?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20%22maximum%20recursion%20depth%20exceeded%22%20error%20in%20Dify%20v1.9.1%20with%20a%20locally%20deployed%20model%20is%20a%20known%20issue%2C%20most%20often%20caused%20by%20incompatibility%20between%20gevent%2025.9.1%20and%20Python%203.12%27s%20SSL%20module%20monkey%20patching.%20This%20triggers%20infinite%20recursion%20in%20SSLContext%20and%20can%20affect%20LLM%20nodes%2C%20especially%20in%20Docker%20deployments.%20The%20recommended%20fix%20is%20to%20downgrade%20gevent%20to%2024.11.1%20in%20your%20Docker%20environment.%20You%20can%20do%20this%20by%20adding%20the%20following%20to%20your%20Dockerfile%3A%0A%0A%60%60%60dockerfile%0AFROM%20langgenius/dify-api%3A1.9.1%0ARUN%20pip%20install%20--no-cache-dir%20gevent%3D%3D24.11.1%0A%60%60%60%0A%0AMake%20sure%20monkey%20patching%20is%20applied%20before%20any%20SSL%20or%20requests%20imports%20in%20your%20startup%20scripts%20to%20avoid%20similar%20issues.%20%0A%0AIf%20your%20workflow%20uses%20knowledge%20base%20retrieval%20or%20hybrid%20search%2C%20also%20check%20your%20%60top_k%60%20settings%20and%20avoid%20broad%20metadata%20filters%20or%20hybrid%20search%20with%20rerank%20on%20large%20datasets%2C%20as%20these%20can%20also%20cause%20recursion%20errors%20if%20too%20many%20documents%20are%20returned%20at%20once.%20Recent%20versions%20include%20deduplication%20fixes%20for%20this%20scenario%2C%20so%20upgrading%20Dify%20may%20help%20if%20you%20continue%20to%20see%20recursion%20errors%20even%20after%20the%20gevent%20change.%0A%0AReferences%3A%20%20%0A-%20%5Bgevent/Python%203.12%20recursion%20error%20and%20fix%5D%28https%3A//github.com/langgenius/dify/issues/26689%29%20%20%0A-%20%5BKnowledge%20base%20retrieval%20recursion%20error%20and%20mitigation%5D%28https%3A//github.com/langgenius/dify/discussions/30446%29%20%20%0A-%20%5BDeduplication%20fix%20for%20hybrid%20search%20recursion%5D%28https%3A//github.com/langgenius/dify/issues/28035%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31731)
Author
Owner

@Zz-lo commented on GitHub (Jan 29, 2026):

Alright, thanks. I'll give it a try on my end first.

@Zz-lo commented on GitHub (Jan 29, 2026): Alright, thanks. I'll give it a try on my end first.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21982