langflow icon indicating copy to clipboard operation
langflow copied to clipboard

Langflow cache type: Redis connection issue

Open MikaHollander opened this issue 1 year ago • 3 comments

Bug Description

Hi, I have a Redis database deployed on Azure that I'm trying to connect to LangFlow. I first set the environment variables as specified in the documentation. However, since my database requires authentication, I wasn't able to connect right away.

I then added the LANGFLOW_REDIS_PASSWORD environment variable, but that also didn’t work. After digging into the code, I found that a Redis URL can also be used for the connection. I couldn’t find an existing environment variable for this URL, but I noticed that LANGFLOW_REDIS_URL is referenced in the settings, so I tried using that. This however also didnt succeed.

I was able to connect to redis locally via python the same as is being done in langflow:

from redis import StrictRedis

redis_url = "redis://:PASSWORD@HOST:6379/0"

client = StrictRedis.from_url(redis_url)

print(client.ping()) 

Reproduction

connect a azure hosted redis db with auth (no SSL) setting the envs like: https://docs.langflow.org/environment-variables.

Expected behavior

cache flowing in redis db after succesfull connection

Who can help?

No response

Operating System

Macos

Langflow Version

1.1.1

Python Version

3.11

Screenshot

No response

Flow File

No response

MikaHollander avatar Feb 27 '25 10:02 MikaHollander

Hey @MikaHollander! I'm here to help you with the issue you're facing. Let's tackle this together!

To connect your Azure-hosted Redis database to LangFlow, ensure that you have correctly set the necessary environment variables. Here’s a checklist to help you troubleshoot the connection issue:

  1. Set the Cache Type:

    • Ensure that the cache type is set to Redis:
      LANGFLOW_CACHE_TYPE=redis
      
  2. Configure Redis Connection Details:

    • Use the LANGFLOW_REDIS_URL to specify the connection string, which should include the host, port, and database number. If your Redis instance requires a password, include it in the URL:
      LANGFLOW_REDIS_URL=redis://:<your_redis_password>@<your_redis_host>:<your_redis_port>/<your_redis_db>
      
    • Alternatively, you can set these individually:
      LANGFLOW_REDIS_HOST=<your_redis_host>
      LANGFLOW_REDIS_PORT=<your_redis_port>
      LANGFLOW_REDIS_DB=<your_redis_db>
      LANGFLOW_REDIS_PASSWORD=<your_redis_password>
      
  3. Check for Errors:

    • If the connection fails, LangFlow should raise a ConnectionError with the message "Failed to connect to Redis cache" [1].
  4. Fallback Mechanism:

    • If the Redis connection fails, LangFlow will fall back to an in-memory cache [2].

Ensure that all placeholders (<your_redis_host>, <your_redis_port>, <your_redis_db>, <your_redis_password>) are replaced with your actual Redis instance details. If the issue persists, double-check the values and ensure there are no typos or misconfigurations.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Feb 27 '25 10:02 dosubot[bot]

You can get it to work like this:

LANGFLOW_REDIS_URL=rediss://:${AZURE_REDIS_ACCESS_KEY}@${LANGFLOW_REDIS_HOST}:${LANGFLOW_REDIS_PORT}?ssl_cert_reqs=none

GarrettGeorge avatar Mar 14 '25 18:03 GarrettGeorge

Hi, @MikaHollander. I'm Dosu, and I'm helping the langflow team manage their backlog. I'm marking this issue as stale.

Issue Summary

  • You experienced a connection issue between LangFlow and a Redis database on Azure.
  • I provided a checklist for troubleshooting, including cache type and connection details.
  • GarrettGeorge suggested a solution using a specific LANGFLOW_REDIS_URL format with Azure Redis access key and SSL requirements.
  • The issue seems to be resolved with GarrettGeorge's suggestion.

Next Steps

  • Please confirm if this issue is still relevant to the latest version of the langflow repository. If so, you can keep the discussion open by commenting on the issue.
  • Otherwise, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Jun 13 '25 16:06 dosubot[bot]