Skip to content

Instantly share code, notes, and snippets.

@anupkrbid
Last active January 9, 2025 06:48
Show Gist options
  • Save anupkrbid/a059b3457dcda26868044e1a556776dd to your computer and use it in GitHub Desktop.
Save anupkrbid/a059b3457dcda26868044e1a556776dd to your computer and use it in GitHub Desktop.

Install Redis on macOS

Use Homebrew to install and start Redis on macOS

This guide shows you how to install Redis on macOS using Homebrew. Homebrew is the easiest way to install Redis on macOS. If you'd prefer to build Redis from the source files on macOS, see Installing Redis from Source.

Prerequisites

First, make sure you have Homebrew installed. From the terminal, run:

brew --version

If this command fails, you'll need to follow the Homebrew installation instructions.

Installation

From the terminal, run:

brew install redis

This will install Redis on your system.

Starting and stopping Redis in the foreground

To test your Redis installation, you can run the redis-server executable from the command line:

redis-server

If successful, you'll see the startup logs for Redis, and Redis will be running in the foreground.

To stop Redis, enter Ctrl-C.

Starting and stopping Redis using launchd

As an alternative to running Redis in the foreground, you can also use launchd to start the process in the background:

brew services start redis

This launches Redis and restarts it at login. You can check the status of a launchd managed Redis by running the following:

brew services info redis

If the service is running, you'll see output like the following:

redis (homebrew.mxcl.redis)
Running: ✔
Loaded: ✔
User: miranda
PID: 67975

To stop the service, run:

brew services stop redis

Connect to Redis

Once Redis is running, you can test it by running redis-cli:

redis-cli

Test the connection with the ping command:

127.0.0.1:6379> ping
PONG

You can also test that your Redis server is running using Redis Insight.

Next steps

Once you have a running Redis instance, you may want to:

@anupkrbid
Copy link
Author

anupkrbid commented Dec 28, 2024

brew install redis # install redis
redis-cli # run redis in terminal
brew services start redis  # start redis as a service in the background
brew services info redis # shows the stats about the redis running in the background
brew services stop redis # stop the redis service running in the background

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment