# Error Connecting to Ollama for Embeddings in CrewAI Memory (Failed to connect to Ollama)

**URL:** <https://community.crewai.com/t/error-connecting-to-ollama-for-embeddings-in-crewai-memory-failed-to-connect-to-ollama/5209>\
**Category:** CrewAI Community Support\
**Tags:** tools\_issues, agent, task, crewai, memory\
**Created:** [April 8, 2025, 11:54am UTC](https://community.crewai.com/t/error-connecting-to-ollama-for-embeddings-in-crewai-memory-failed-to-connect-to-ollama/5209 "2025-04-08T11:54:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nir](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@nir](https://community.crewai.com/u/nir)\
**Post date:** [April 8, 2025, 11:54am UTC](https://community.crewai.com/t/error-connecting-to-ollama-for-embeddings-in-crewai-memory-failed-to-connect-to-ollama/5209/1 "2025-04-08T11:54:42Z")

</div>

# the original URL as specified

OLLAMA\_BASE\_URL = ‘XYZ’

LLM\_MODEL = ‘ollama/llama3.1:8b’ # This model exists in my server

EMBEDDING\_MODEL = ‘nomic-embed-text:latest’ # This model exists in my server

# Embedder configuration for Ollama

OLLAMA\_EMBEDDER\_CONFIG = {  
“provider”: “ollama”,  
“config”: {  
“model”: EMBEDDING\_MODEL,  
“ollama\_base\_url”: OLLAMA\_BASE\_URL,  
}  
}

# Initialize memory components

ltm = LongTermMemory(storage=LTMSQLiteStorage(db\_path=LTM\_DB\_PATH))  
stm = ShortTermMemory(storage=RAGStorage(  
embedder\_config=OLLAMA\_EMBEDDER\_CONFIG,  
path=STM\_RAG\_PATH,  
type=“short\_term”  
))  
em = EntityMemory(storage=RAGStorage(  
embedder\_config=OLLAMA\_EMBEDDER\_CONFIG,  
path=EM\_RAG\_PATH,  
type=“short\_term”  
))

# Initialize CrewAI Crew

chatbot\_crew = Crew(  
agents=[assistant\_agent],  
tasks=[assistant\_task],  
process=Process.sequential,  
memory=True,  
long\_term\_memory=ltm,  
short\_term\_memory=stm,  
entity\_memory=em,  
verbose=True,  
embedder=OLLAMA\_EMBEDDER\_CONFIG  
)

ERROR :2025-04-08 17:10:08 - Error during short\_term search: Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. [Download Ollama on Linux](https://ollama.com/download) in query.  
2025-04-08 17:10:12 - Error during short\_term search: Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. [Download Ollama on Linux](https://ollama.com/download) in query.

NOTE : all the models are working properly and are in running condition

---

<div class="post-metadata">

**Author:** ![zinyando](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/zinyando/32/4435_2.png) [@zinyando](https://community.crewai.com/u/zinyando)\
**Post date:** [April 8, 2025, 4:28pm UTC](https://community.crewai.com/t/error-connecting-to-ollama-for-embeddings-in-crewai-memory-failed-to-connect-to-ollama/5209/2 "2025-04-08T16:28:28Z")

</div>

What happens if you use the same config when using it with `LLM` in an agent, does it work?

Does the Ollama config only fail for embeddings?

---

<div class="post-metadata">

**Author:** ![nir](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@nir](https://community.crewai.com/u/nir)\
**Post date:** [April 8, 2025, 7:23pm UTC](https://community.crewai.com/t/error-connecting-to-ollama-for-embeddings-in-crewai-memory-failed-to-connect-to-ollama/5209/3 "2025-04-08T19:23:49Z")

</div>

Yes with same config it works and ollama embeddings didn’t fail when I tried to run with mem0 config where I provided same ollama embedding it worked perfectly but when I take STM and ETM I am not able to get the output it’s showing error

---

<div class="post-metadata">

**Author:** ![nir](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@nir](https://community.crewai.com/u/nir)\
**Post date:** [April 9, 2025, 4:49am UTC](https://community.crewai.com/t/error-connecting-to-ollama-for-embeddings-in-crewai-memory-failed-to-connect-to-ollama/5209/4 "2025-04-09T04:49:05Z")

</div>

@zinyando any inputs to fix the error
