Skip to content

How to Install Redis?

You can install Redis on Mac, Linux and Windows. The official instruction can be found here .

Install Redis on Windows

curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

sudo apt-get update
sudo apt-get install redis

Start and connect Redis on Windows

# Start the Redis Server
sudo service redis-server start

# Build the connection
redis-cli 

Install Redis on macOS

brew install redis

Start and stop Redis in the foreground

redis-server

# you will see
2891:C 04 Apr 2024 13:59:43.994 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=2891, just started
2891:C 04 Apr 2024 13:59:43.994 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
2891:M 04 Apr 2024 13:59:43.995 * Increased maximum number of open files to 10032 (it was originally set to 256).
2891:M 04 Apr 2024 13:59:43.995 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 7.2.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 2891
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

2891:M 04 Apr 2024 13:59:43.996 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
2891:M 04 Apr 2024 13:59:43.996 * Server initialized
2891:M 04 Apr 2024 13:59:44.003 * Loading RDB produced by version 7.2.4
2891:M 04 Apr 2024 13:59:44.003 * RDB age 138835 seconds
2891:M 04 Apr 2024 13:59:44.003 * RDB memory usage when created 1.03 Mb
2891:M 04 Apr 2024 13:59:44.003 * Done loading RDB, keys loaded: 0, keys expired: 0.
2891:M 04 Apr 2024 13:59:44.003 * DB loaded from disk: 0.007 seconds
2891:M 04 Apr 2024 13:59:44.003 * Ready to accept connections tcp

To stop Redis, enter Ctrl-C.

^C2891:signal-handler (1712232030) Received SIGINT scheduling shutdown...
2891:M 04 Apr 2024 14:00:30.081 * User requested shutdown...
2891:M 04 Apr 2024 14:00:30.081 * Saving the final RDB snapshot before exiting.
2891:M 04 Apr 2024 14:00:30.089 * DB saved on disk
2891:M 04 Apr 2024 14:00:30.089 # Redis is now ready to exit, bye bye...

Start and stop Redis using launchd

# Start redis service
brew services start redis

# You will see 
Service `redis` already started, use `brew services restart redis` to restart.
# Check the status
brew services info redis

# You will see
redis (homebrew.mxcl.redis)
Running: ✔
Loaded: ✔
Schedulable: ✘
User: ivyw
PID: 438
# Stop the service
brew services stop redis

# You will see
Stopping `redis`... (might take a while)
==> Successfully stopped `redis` (label: homebrew.mxcl.redis)

Connect to Redis using redis-cli

redis-cli

# If the connection is built, you will see
127.0.0.1:6379> 

Verify the connection

ping

#You will get a "PONG" as response
127.0.0.1:6379> ping
PONG
Tags: