Skip to main content
Redis Basics
CHAPTER 02 Intermediate

How to Install Redis on Windows, Mac, and Linux

Updated: May 16, 2026
15 min read

# CHAPTER 2

Installing Redis and Redis CLI

1. Introduction

Before you can start caching data and building real-time applications, you must physically install the Redis engine on your computer. Unlike XAMPP or MySQL, which come with friendly .exe graphical installers, Redis was built by Linux engineers, for Linux servers. It does not have an official native Windows version. In this chapter, we will learn how to properly install Redis across all operating systems and use the terminal to interact with it.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Install Redis natively on Linux (Ubuntu).
  • Install Redis on macOS using Homebrew.
  • Install Redis on Windows using WSL (Windows Subsystem for Linux).
  • Start and stop the Redis Server.
  • Use the redis-cli to ping the server.

3. Installing Redis on Linux (Ubuntu)

This is the native, intended environment for Redis.
  1. 1. Open your terminal.
  1. 2. Update your package manager:
``bash sudo apt update `
  1. 3. Install the Redis server:
`bash sudo apt install redis-server `
  1. 4. Redis will automatically start running in the background as a service!

4. Installing Redis on macOS

Apple developers use a package manager called Homebrew.
  1. 1. Open the macOS Terminal.
  1. 2. Ensure Homebrew is installed (brew.sh).
  1. 3. Install Redis:
`bash brew install redis `
  1. 4. Start the Redis background service:
`bash brew services start redis `

5. Installing Redis on Windows

Because Redis doesn't officially support Windows natively, we must use WSL (Windows Subsystem for Linux), which allows you to run a real Ubuntu Linux terminal directly inside Windows!
  1. 1. Open PowerShell as Administrator.
  1. 2. Install WSL:
`powershell wsl --install `
  1. 3. Restart your computer.
  1. 4. Open the new "Ubuntu" app from your Windows Start Menu. You are now in a Linux terminal!
  1. 5. Run the Linux commands:
`bash sudo apt update sudo apt install redis-server `
  1. 6. Start the server manually:
`bash sudo service redis-server start `

6. The Redis CLI (Command Line Interface)

Now that the server is running in the background, we need to talk to it. Redis comes with a built-in terminal tool called
redis-cli.
  1. 1. Open your terminal (or your WSL Ubuntu window).
  1. 2. Type exactly:
`bash redis-cli `
  1. 3. Press Enter. Your terminal prompt will change to: 127.0.0.1:6379>.
  • 127.0.0.1 means Localhost (your computer).
  • 6379 is the official port number that Redis always runs on!

7. Your First Redis Command

Let's see if the server is actually listening.
  1. 1. Inside the redis-cli, type:
`bash PING `
  1. 2. Press Enter.
  1. 3. The server should instantly reply:
`bash PONG ` Congratulations! You are officially communicating with a live In-Memory database.

8. Mini Project: Hello World

Let's store our first piece of data in RAM.
  1. 1. Inside the redis-cli, write a Key-Value pair:
`bash SET message "Hello World!" ` *(Redis responds: OK)*
  1. 2. Now, retrieve the data using the Key:
`bash GET message ` *(Redis responds: "Hello World!")*
  1. 3. To exit the CLI and go back to your normal terminal, type exit.

9. Common Mistakes

  • Forgetting to start the server: If you type redis-cli and get an error saying *"Could not connect to Redis at 127.0.0.1:6379: Connection refused"*, it means the actual Redis Server program is not running in the background. You must run sudo service redis-server start (or the Homebrew equivalent) before using the CLI.

10. Best Practices

  • Embrace the Terminal: Do not search for a "phpMyAdmin for Redis." While GUI tools like *RedisInsight* exist and are very good, professional developers interact with Redis almost exclusively through the terminal or via backend code. Embrace the redis-cli; it is the fastest way to debug caching issues on a live server.

11. Exercises

  1. 1. What is the default port number that the Redis server listens on?
  1. 2. What command do you type into the redis-cli to check if the server is alive and responding?

12. Redis Challenges

You are a Windows user trying to install Redis. You find an old
.msi Windows installer file from 2016 on a third-party website. Should you use this file to install Redis? Why or why not, and what is the modern architectural alternative? *(Answer: No, you should never use outdated, unofficial Windows ports of Redis, as they lack modern features, security patches, and official support. The industry standard workflow for Windows developers is to install WSL (Windows Subsystem for Linux) and run the official, native Linux version of Redis directly inside Windows).*

13. MCQ Quiz with Answers

Question 1

When interacting with Redis via the redis-cli, what response indicates that the server is successfully running, listening on port 6379, and ready to accept commands?

Question 2

Why is the installation process for Redis on Windows fundamentally different than on macOS or Ubuntu?

14. Interview Questions

  • Q: You are onboarding a new Windows developer to your team. Outline the exact architectural steps required to get a production-equivalent Redis server running locally on their Windows machine using WSL.
  • Q: Explain the function of the redis-cli. How does it connect to the server, and what is the default host and port used?

15. FAQs

Q: I restarted my computer, and the data I saved with
SET message is gone! Why? A: Welcome to In-Memory databases! By default, if the Redis server shuts down, the RAM is cleared. We will learn how to make the data permanent (Persistence) in Chapter 9.

16. Summary

You have successfully deployed a blazing-fast memory server. By utilizing native Linux packages, Homebrew, or WSL, you have started the Redis service on port 6379, connected to it using the
redis-cli`, and successfully Pinged the engine.

17. Next Chapter Recommendation

We know how to store a simple text string. But Redis is much more powerful than just a basic text dictionary. In Chapter 3: Understanding Redis Data Structures, we will explore the 5 foundational data types that make Redis the most versatile caching tool on the planet.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·