This tutorial explains how to stop the Redis server.

First, check Redis server is running or not using redis-cli.

Run the redis-cli ping command and it gives pong if the server already running

A:\Java\Redis>redis-cli ping

If the server is not running, It gives an error.

Let’s see how to stop the Redis server in Windows, Linux, Unix, and MAC

How to stop Redis server in Windows

In Windows, You can do it in two ways.

The first way, open the terminal in Redis CLI interactive mode using the redis-cli command, It connects to the redis server, next, type the shutdown command, it shutdowns the server, and redis-cli is disconnected from a server.

A:\Java\Redis>redis-cli> shutdown
not connected>

Another way is if Redis service is installed services.

Go to Services using the Window + R command, type “Services.msc” Select Redis server, right-click and select the stop option It shutdowns the redis server and saves the data in memory.

You can also use the shutdown nosave option to ignore saving the data in memory.

Redis shutdown in Linux or UNIX

There are multiple ways to shut down in Unix and Linux OS

The first way is to find the process id of a redis server using the server name or process pid.

The below command displays the process id for redis-server.

ps aux | grep redis-server

Next, Kill the process using the process id

kill -9 processid

For services command users,

sudo service redis-server stop
sudo service redis-server start
sudo service redis-server restart

For systemctl command users such as Ubuntu, You can use the below commands is-active - Redis server is active or not is-enabled: enabled or not disable: Redis server is disabled

sudo systemctl is-active redis-server
sudo systemctl is-enabled redis-server
sudo systemctl stop redis-server
sudo systemctl disable redis-server

Finally, you can use a redis-cli command to shutdown the server

redis-cli shutdown
redis-cli shutdown nosave

Redis stop server in macOS

The first way, you can use the redis-cli command to shutdown the server

redis-cli shutdown
redis-cli shutdown nosave

For homebrew users, you can use the below commands brew services

brew services start redis
brew services stop redis
brew services restart redis

Redis stop server in docker container

First, using the docker ps command list out docker container information such as id and ports

docker ps

Next, Run the docker stop command with the process id returned from the above command.

docker stop container_id