Install Redis Open Source on macOS
How to install Redis Open Source on macOS using Homebrew
| Redis Open Source |
|---|
Install Redis Open Source on macOS using Homebrew
redis-cli) and not the full Redis Open Source distribution, see Install redis-cli.To install Redis Open Source on macOS, use the Homebrew formula called redis.
Make sure that you have Homebrew installed before you start.
The formula is the preferred way to install Redis Open Source on macOS. A Homebrew cask is also available, but it is not integrated with brew services and requires a separate tap.
Install using Homebrew
Run brew install:
brew install redisThis installs the latest Redis Open Source release, including Redis Search and the JSON, time series, probabilistic, and vector set data structures.
If you already have Redis installed through Homebrew, see Upgrade an existing installation instead.
Upgrade an existing installation
Upgrade from an earlier version of the formula
If you previously installed Redis using the redis formula, upgrade it with the following command:
brew upgrade redisHomebrew does not overwrite a configuration file that you might have changed. It leaves your existing redis.conf in place and writes the new default configuration to redis.conf.default. Because the older configuration file does not contain the loadmodule directives, Redis Search and the additional data structures stay disabled until you use the new default.
-
Compare your configuration file with the new default:
diff $(brew --prefix)/etc/redis.conf $(brew --prefix)/etc/redis.conf.default -
Back up your configuration file:
cp $(brew --prefix)/etc/redis.conf $(brew --prefix)/etc/redis.conf.backup -
Replace your configuration file with the new default:
cp $(brew --prefix)/etc/redis.conf.default $(brew --prefix)/etc/redis.confIf you had customized any settings, reapply them to the new file.
-
Restart Redis, then check the results as described in Verify that all modules are loaded correctly.
Migrate from the Redis cask
If you previously installed Redis Open Source using the Redis Homebrew cask, remove it before you install the formula. Both provide the redis-server and redis-cli binaries in the same location.
-
Uninstall the cask:
brew uninstall --cask redis -
Remove the tap:
brew untap redis/redis -
Check if the
redis.conffile is still installed:ls -l $(brew --prefix)/etc/redis.confIf you get output similar to the following, then it's still there:
-rw-r--r--@ 1 user admin 122821 2 Oct 16:07 /opt/homebrew/etc/redis.confRun this command to remove the file:
rm -iv $(brew --prefix)/etc/redis.confThe configuration file installed by the cask loads the modules from a directory that the cask removes when you uninstall it. If you leave the file in place,
redis-serverfails to start, and Homebrew does not replace it.
Next, follow the instructions in Install using Homebrew.
Run Redis
If this is the first time you've installed Redis on your system, you need to be sure that your PATH variable includes the Redis installation location. This location is either /opt/homebrew/bin for Apple silicon Macs or /usr/local/bin for Intel-based Macs.
To check this, run:
echo $PATHNext, confirm that the output contains /opt/homebrew/bin (Apple silicon Macs) or /usr/local/bin (Intel Mac). If neither /opt/homebrew/bin nor /usr/local/bin are in the output, add them.
Open the file ~/.bashrc or ~/.zshrc (depending on your shell), and add the following line.
export PATH=$(brew --prefix)/bin:$PATHYou can now start Redis in one of two ways.
To start Redis now and restart it at login, run it as a Homebrew service:
brew services start redisThe service runs redis-server with the configuration file at $(brew --prefix)/etc/redis.conf.
If you don't need a background service, start the server directly:
redis-server $(brew --prefix)/etc/redis.confThe server will run in the background.
Connect to Redis
Once Redis is running, you can test it by running redis-cli:
redis-cliTest the connection with the ping command:
127.0.0.1:6379> PING
PONGVerify that all modules are loaded correctly
If you upgraded from an earlier Redis installation, for example 7.2.x or 7.4.x, test to see if all the modules are loaded correctly by running the following command. Your output should look similar to the following:
$ redis-cli MODULE LIST
1) 1) "name"
2) "timeseries"
3) "ver"
4) (integer) 80991
5) "path"
6) "/usr/local/lib/redis/modules//redistimeseries.so"
7) "args"
8) (empty array)
2) 1) "name"
2) "search"
3) "ver"
4) (integer) 80990
5) "path"
6) "/usr/local/lib/redis/modules//redisearch.so"
7) "args"
8) (empty array)
3) 1) "name"
2) "bf"
3) "ver"
4) (integer) 80990
5) "path"
6) "/usr/local/lib/redis/modules//redisbloom.so"
7) "args"
8) (empty array)
4) 1) "name"
2) "vectorset"
3) "ver"
4) (integer) 1
5) "path"
6) ""
7) "args"
8) (empty array)
5) 1) "name"
2) "ReJSON"
3) "ver"
4) (integer) 80990
5) "path"
6) "/usr/local/lib/redis/modules//rejson.so"
7) "args"
8) (empty array)If the list is empty, your configuration file does not load the modules. See Upgrade from an earlier version of the formula.
Stop Redis
If you started Redis as a Homebrew service, run:
brew services stop redisOtherwise, run:
redis-cli SHUTDOWNUninstall Redis Open Source
If you started Redis as a Homebrew service, stop the service first:
brew services stop redisTo uninstall Redis, run:
brew uninstall redisAlternative: install using the Redis cask
Redis also provides a Homebrew cask. First, tap the Redis Homebrew cask:
brew tap redis/redisOn Homebrew 6.0 and later, you also need to trust the tap. This step is not required on earlier versions of Homebrew.
brew trust redis/redisNext, run brew install:
brew install --cask redisStart the server with the configuration file that the cask installs:
redis-server $(brew --prefix)/etc/redis.confbrew tap command, it is not integrated with the brew services command.To uninstall the cask, run:
brew uninstall --cask redis
brew untap redis/redisNext steps
Once you have a running Redis instance, you may want to:
- Try the Redis CLI tutorial
- Connect using one of the Redis clients
- Connect using Redis Insight