Redis.conf file

redis.conf logoRedis could be easily configured with help of redis.conf file. It is located inside your Redis installation directory. This file contains default configuration that is recommended for development phase.

You can replace the default values and set ones for your specific needs. Redis.conf structure is also simple. It consists of lines with parameter and values separated by spaces:

parameter value1 value2 … valueN

A real example (port parameter):

port 6379

In this article we list the main parameters of Redis configuration.

General redis.conf parameters

Parameter Description Default
daemonize When set to ‘yes’ Redis will run as a deamon no
pidfile Custom pid file location /var/run/
port Custom port; if set to 0 Redis will not listen on a TCP socket 6379
timeout Time in seconds of client idle period after which connection will be closed 0
tcp-keepalive Time in seconds that specifies the period to send TCP ACKs to client 0
loglevel Verbosity level. Possible: debug, verbose, notice, warning. notice
logfile Specifies the log file location. If empty string, stdout will be used. “”
databases Number of databases 16

Snapshotting with redis.conf

Parameter Description Default
save <seconds> <changes> Will save DB on disk if after <seconds> period appeared <changes> number of changes 900 1300 1060 10000
stop-writes-on-bgsave-error Stop the writing if RDB snapshots are enabled and the lates save failed yes
rdbcompression Compressing strings using LZF yes
rdbchecksum Place CRC4 checksum in the end of file yes
dbfilename Custom name for a dump file dump.rdb
dir Working directory ./

Replication redis.conf parameters

Parameter Description Default
slaveof <masterip> <masterport> Makes Redis instance replicate another instance
masterauth <master-password> If ‘requirepass’ is enabled, masterauth tells slaves to authenticate before synchronization with <master-password>
slave-serve-stale-data If set to no, slave instance will not serve client request when connection with the master is list or replication is in progress yes
slave-read-only If set to no, slave instance will accept writes to store temporary writes that will be overwritten after next sync yes
repl-timeout Replication timeout
slave-priority The integer for selecting the new master between slaves if master is not working 100
min-slaves-to-write If there is less active slaves than this number, master will disable writes

Security settings

Parameter Description
Requirepass <password> Client will need to provide a password before each command
rename-command <from> <to> Changes specified command to a new name. It helps to disable some commands when providig an empty string instead of <to>



Parameter Description
maxclients Sets the limit of live connections
maxmemory <bytes> Sets the limit of memory used
maxmemory-policy What to do if memory id reached:

volatile-lru – remove the key with an expire set using the LRU algorithm;allkeys-lru – remove any key with LRU;volatile-random – remove a random key with an expire set;allkeys-random – remove a random key;volatile-ttl – remove the key with the smallest TTL;noeviction – return an error on write operations;

maxmemory-samples <number> Number of keys to pick one for deletion (less used)

Append-only mode

If the Redis process is interrupted by different reason it may cause a loss of writes for last couple minutes. To prevent it there is an append-only mode that allows persistence. This mode writes all data in a file on disk.

Parameter Description Default
appendonly Enable append-only mode no
appendfilename Customize append-only file name “appendonly.aof”

Redis cluster

Parameter Description
cluster-enabled When set to yes, node will start as a part of Redis cluster
cluser-config-file Specifies the name of a cluster config-file

To get advanced details read official documentation.


Leave a Reply

1 Comment on "Redis.conf file"

1 year 6 months ago

Thank you! Very useful.