Skip to main content
The bench setup redis command generates Redis configuration files for both cache and queue services used by Frappe.

Usage

bench setup redis
This command takes no options and generates configuration based on your bench’s common_site_config.json.

What It Does

1

Read Configuration

Reads Redis port settings from sites/common_site_config.json:
  • redis_cache: Port for cache server (default: 13000)
  • redis_queue: Port for queue server (default: 11000)
2

Generate redis_queue.conf

Creates config/redis_queue.conf for the queue server.Used for background job processing via RQ (Redis Queue).
3

Generate redis_cache.conf

Creates config/redis_cache.conf for the cache server.Includes memory limits based on system RAM (5% by default, minimum 50MB).
4

Create PID Directory

Creates config/pids/ directory for Redis process ID files.
5

Setup ACL Files (Redis 6+)

If Redis version is 6.0 or higher, creates ACL (Access Control List) files:
  • config/redis_queue.acl
  • config/redis_cache.acl

Generated Files

File Locations

frappe-bench/
├── config/
│   ├── redis_cache.conf      # Cache server configuration
│   ├── redis_queue.conf      # Queue server configuration
│   ├── redis_cache.acl       # Cache ACL (Redis 6+)
│   ├── redis_queue.acl       # Queue ACL (Redis 6+)
│   └── pids/                 # Process ID files

Configuration Details

redis_cache.conf includes:
  • Port configuration
  • Memory limits (maxmemory)
  • Eviction policy (LRU)
  • RDB persistence disabled
  • AOF persistence settings
redis_queue.conf includes:
  • Port configuration
  • Persistence settings
  • Save intervals for data durability
  • Background save settings

Examples

Basic Setup

Generate Redis configuration:
bench setup redis

After Changing Ports

If you modify Redis ports in common_site_config.json, regenerate the config:
# Edit ports in common_site_config.json
nano sites/common_site_config.json

# Regenerate Redis configuration
bench setup redis

# Restart Redis servers
bench restart

Custom Cache Memory

Set custom maximum memory for Redis cache:
// sites/common_site_config.json
{
  "redis_cache": "redis://localhost:13000",
  "redis_queue": "redis://localhost:11000",
  "cache_maxmemory": 512
}
Then regenerate:
bench setup redis

Technical Details

Memory Calculation

The cache memory limit is automatically calculated as:
max(50, int((total_system_memory * 0.05)))
  • Uses 5% of total system RAM
  • Minimum of 50 MB
  • Can be overridden with cache_maxmemory in config

Redis Version Detection

The command detects your Redis version:
redis-server --version
ACL features are only enabled for Redis 6.0+.

Port Configuration

Default ports if not specified:
ServiceDefault PortConfig Key
Cache13000redis_cache
Queue11000redis_queue
SocketIOSame as cacheredis_socketio

When to Use

Initial Setup

This command is automatically run during bench init. You typically don’t need to run it manually.

After Port Changes

Regenerate configuration after changing Redis ports in your config.

Multi-Bench Setup

When running multiple benches on the same server, ensure each bench uses unique Redis ports:
// Bench 1
{
  "redis_cache": "redis://localhost:13000",
  "redis_queue": "redis://localhost:11000"
}

// Bench 2
{
  "redis_cache": "redis://localhost:13001",
  "redis_queue": "redis://localhost:11001"
}

Troubleshooting

Redis Connection Errors

If you see “Could not connect to Redis”:
# Check if Redis is running
supervisorctl status

# Check Redis configuration
cat config/redis_cache.conf
cat config/redis_queue.conf

# Regenerate and restart
bench setup redis
bench restart

Port Conflicts

If Redis fails to start due to port conflicts:
  1. Check what’s using the port:
    sudo lsof -i :13000
    
  2. Change the port in common_site_config.json
  3. Regenerate configuration:
    bench setup redis
    

Source Code

Implementation: bench/config/redis.py:10

Build docs developers (and LLMs) love