content/operate/oss_and_stack/install/install-stack/homebrew.md
{{< note >}}Installation using Homebrew is only supported on macOS.{{< /note >}}
To install Redis Open Source on macOS, use Homebrew. Make sure that you have Homebrew installed before starting on the installation instructions below.
If you had previously installed Redis on your system using the default Homebrew formula called "redis", you need to remove it before installing Redis Open Source 8.x.
Follow these steps to remove any existing Redis installation files:
Uninstall Redis:
brew uninstall redis
Next check if the redis.conf file is still installed:
ls -l $(brew --prefix)/etc/redis.conf
If 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.conf
Run this command to remove the file:
rm -iv $(brew --prefix)/etc/redis.conf
Next, follow the instructions in the next section to install Redis Open Source 8.x using the Redis Homebrew cask.
First, tap the Redis Homebrew cask:
{{< highlight bash >}} brew tap redis/redis {{< /highlight >}}
Next, run brew install:
{{< highlight bash >}} brew install --cask redis {{< /highlight >}}
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:
{{< highlight bash >}} echo $PATH {{< /highlight >}}
Next, 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.
{{< highlight bash >}} export PATH=$(brew --prefix)/bin:$PATH {{< /highlight >}}
You can now start the Redis server as follows:
{{< highlight bash >}} redis-server $(brew --prefix)/etc/redis.conf {{< /highlight >}}
The server will run in the background.
{{< note >}}
Because Redis is installed using a Homebrew cask with the brew tap command, it will not be integrated with the brew services command.
{{< /note >}}
Once Redis is running, you can test it by running redis-cli:
{{< highlight bash >}} redis-cli {{< /highlight >}}
Test the connection with the ping command:
{{< highlight bash >}} 127.0.0.1:6379> PING PONG {{< /highlight >}}
If you had previously installed earlier versions of Redis using Homebrew, for example 7.2.x or 7.4.x, you should test to see if all the modules are loaded correctly by running the following command. Your output should look similar to the following:
{{< highlight bash >}} $ redis-cli MODULE LIST
Run the following command:
{{< highlight bash >}} redis-cli SHUTDOWN {{< /highlight >}}
To uninstall Redis, run:
{{< highlight bash >}} brew uninstall redis brew untap redis/redis {{< /highlight >}}
Once you have a running Redis instance, you may want to: