How to Connect n8n to Redis: Cache Data and Speed Up Your Workflows (2025)
Redis is the missing piece in most n8n setups. It's a lightning-fast in-memory store, and once you connect it to n8n you can cache expensive API calls, remember state between runs, deduplicate incoming data, and rate-limit workflows — all things n8n can't do well on its own. Here's how to wire it up.
Step 1: Get a Redis instance
You have three easy options: run Redis in Docker alongside your self-hosted n8n (docker run -p 6379:6379 redis), use a managed service like Redis Cloud or Upstash (both have generous free tiers), or add it to your existing docker-compose stack. Note the host, port, and password.
Step 2: Add the Redis credential in n8n
n8n ships with a native Redis node — no HTTP hacking required. Go to Credentials → New → Redis and enter your host, port, and password. If Redis runs in the same Docker network as n8n, use the container name as the host (e.g., redis) instead of localhost.
🚀 Cut your AI bill by up to 60% with a smart router
Caching is one half of a cost-efficient stack — routing is the other. The n8n LLM Router sends each task to the cheapest model that can handle it, and pairs perfectly with a Redis cache to avoid paying for repeated prompts.
Step 3: Use the Redis node
The Redis node supports the operations you'll actually need:
- Set — store a value, optionally with a TTL (time-to-live) so it auto-expires.
- Get — retrieve a stored value.
- Incr — atomically increment a counter (perfect for rate limiting).
- Keys — list keys matching a pattern.
- Delete — remove a key.
Four high-impact patterns
1. Cache expensive API and AI responses
Before calling a paid API, build a cache key (e.g., a hash of the prompt) and do a Redis Get. If a value exists, use it and skip the call. If not, make the call and Set the result with a TTL. This alone can slash AI and enrichment costs on repetitive workloads.
2. Deduplicate incoming items
Processing a webhook or feed that sometimes sends the same record twice? Use Set with the item's ID as the key and a short TTL. If the key already exists, an IF node routes it to "already processed" and stops. Cleaner and faster than querying a database.
3. Rate-limit calls to fragile APIs
Use Incr against a per-minute key with a 60-second TTL. If the counter exceeds your limit, route the item to a Wait node. This keeps you under third-party rate caps without hard-coding fragile delays.
4. Store state between workflow runs
Scheduled workflows are stateless by default. Store a "last processed timestamp" or "last seen ID" in Redis so each run picks up exactly where the previous one left off — no reprocessing, no gaps.
Best practices
- Always set a TTL on cache keys so Redis doesn't grow unbounded.
- Namespace your keys (
cache:leadscore:123) so different workflows don't collide. - Keep Redis on the same network as n8n to minimize latency.
- Redis is in-memory — treat it as a cache, not your source of truth.
Ready to automate? Combine Redis caching with the LLM Router template and stop overpaying for AI calls. Get this template on Gumroad →