Redis is the backbone of caching, rate limiting, session storage, and job queues in modern applications. The n8n Redis node gives you direct access to Redis from inside your automation workflows — no custom code required.
This guide covers credential setup, every supported operation, real-world patterns, and a free workflow JSON you can import today.
What the n8n Redis Node Can Do
| Operation | What it does |
|---|---|
| Get | Retrieve a value by key |
| Set | Store a key-value pair (with optional TTL) |
| Delete | Remove a key |
| Exists | Check whether a key is present |
| Keys | List keys matching a pattern |
| Increment | Atomically increment a counter |
| Push | Append a value to a Redis list |
| Pop | Remove and return the first/last list item |
| Get All | Retrieve all fields from a hash |
| Set Hash | Set one or more hash fields |
For pub/sub or Lua scripting, use the Execute Command operation which lets you run any raw Redis command.
Credential Setup
In n8n, go to Credentials → New → Redis.
You need:
-
Host — your Redis host (e.g.,
redis-12345.c1.us-east-1-2.ec2.redns.redis-cloud.comor127.0.0.1) - Port — default 6379
- Password — required for Redis Cloud, Upstash, Railway; optional for local
- Database — Redis database index (0–15); defaults to 0
TLS: Toggle on for Redis Cloud, Upstash, and any production Redis. Without TLS, credentials travel in plaintext.
Common gotcha: If you're running n8n in Docker and Redis on the host machine, use host.docker.internal as the host instead of localhost or 127.0.0.1.
Get and Set — The Core Operations
Set a key with TTL
Key Name: user:{{ $json.user_id }}:session
Value: {{ JSON.stringify($json.session_data) }}
TTL (seconds): 3600
Set a TTL whenever you're caching — Redis will auto-expire the key so you don't have to clean up manually.
Get a key
Key Name: user:{{ $json.user_id }}:session
The node returns { "value": "..." }. If the key doesn't exist, value is null — use an IF node downstream to handle the cache-miss branch.
Cache-Aside Pattern
The most common Redis pattern in n8n: check the cache first, fall back to the slow source, write back to cache.
Redis Get → IF (value != null) → [cache hit] return value
→ [cache miss] HTTP Request → Redis Set → continue
This cuts API calls dramatically when the same data is requested repeatedly. Combine with a sensible TTL matching your data's staleness tolerance.
Rate Limiting with INCR
Redis's atomic increment is perfect for rate limiting:
Operation: Increment
Key Name: rate:{{ $json.ip_address }}:{{ new Date().toISOString().slice(0,13) }}
Follow with an IF node: if the returned count > your threshold (e.g., 100), reject the request. The key auto-resets each hour because the timestamp in the key name rolls over.
Job Queue with PUSH/POP
Enqueue: Operation: Push (Left), Key: job_queue, Value: {{ JSON.stringify($json.job) }}
Dequeue: Operation: Pop (Right), Key: job_queue
LPUSH + RPOP = FIFO queue. Combine with an n8n schedule trigger that POPs and processes jobs periodically.
Common Patterns
API Response Caching
Webhook → Redis Get →
IF cache hit → Respond to Webhook (cached value)
IF cache miss → HTTP Request → Redis Set (TTL 300s) → Respond to Webhook
Cache expensive external API calls. With a 5-minute TTL, 100 requests/minute drops to 1 real API call per 5 minutes.
Distributed Counter (page views, signups)
Webhook → Redis Increment (key: counter:signups:{{ new Date().toISOString().slice(0,10) }})
→ Redis Get (same key)
→ Respond with { count: {{ $json.value }} }
Atomic increments mean no race conditions even under concurrent traffic.
Session Token Storage
On login: Redis Set (key: session:{{ token }}, value: {{ userId }}, TTL: 86400)
On request: Redis Get (key: session:{{ $json.token }}) → IF null → 401
Gotchas Table
| Symptom | Root cause | Fix |
|---|---|---|
ECONNREFUSED |
Wrong host/port or Redis not running | Check host (use host.docker.internal in Docker), confirm port 6379 |
NOAUTH error |
Password required but not set in credential | Add the Redis password in n8n credentials |
null value on Get |
Key expired or never set | Handle null branch with IF node; check TTL logic |
| TLS handshake error | TLS toggle off on a TLS-required server | Enable TLS in credentials |
| Key not visible in Redis | Using wrong DB index | Match the database index (0–15) in credentials and your Redis client |
| Increment returning wrong value | Multiple n8n instances sharing a key | Use namespaced keys (include workflow ID or tenant ID) |
Execute Command — Raw Redis
For anything not covered by the built-in operations:
Operation: Execute Command
Command: EXPIRE user:{{ $json.id }}:session 7200
Or for hash operations:
Command: HSET user:{{ $json.id }} email {{ $json.email }} plan {{ $json.plan }}
Execute Command runs any valid Redis command and returns the raw response.
Free Workflow JSON — API Cache with Redis
This workflow receives a request, checks Redis for a cached response, falls back to an HTTP API if needed, caches the result, and responds — all in one workflow.
Drop a comment below and I'll share the full workflow JSON. Tell me which Redis provider you're using (Upstash, Redis Cloud, Railway, or self-hosted) and I'll include the right TLS/auth config.
Workflow Starter Pack ($29)
If you want pre-built, production-ready workflows with error handling, retry logic, and monitoring built in, the n8n Workflow Starter Pack includes a complete cache-aside workflow with Redis alongside 2 other production workflows.
Every workflow is documented, tested, and imports in under 2 minutes.
What do you use Redis for in your n8n workflows — caching, rate limiting, queues, or session storage? Let me know in the comments.
Top comments (1)
Redis provider setup notes for n8n ⚡
Upstash (serverless Redis, free tier):
Redis Cloud (free 30MB tier):
Self-hosted / Docker:
host.docker.internalas host if Redis is on the same machine as n8nWhat Redis provider are you running, and what's your main use case — caching, queues, or rate limiting?