0
0
RedisHow-ToBeginner · 4 min read

How to Install Redis on Windows: Step-by-Step Guide

To install Redis on Windows, you can either use the official Microsoft port available on GitHub or install it via Windows Subsystem for Linux (WSL). The Microsoft port provides a native Windows executable, while WSL allows running the Linux version of Redis directly on Windows.
📐

Syntax

Redis installation on Windows involves downloading and running the Redis server executable or using WSL commands to install Redis in a Linux environment on Windows.

  • redis-server.exe: The Redis server executable for Windows.
  • wsl: Windows Subsystem for Linux command to run Linux commands.
  • sudo apt install redis-server: Linux command to install Redis inside WSL.
bash
redis-server.exe

# Or using WSL
wsl
sudo apt update
sudo apt install redis-server
sudo service redis-server start
💻

Example

This example shows how to install Redis using Windows Subsystem for Linux (WSL) and start the Redis server.

bash
wsl
sudo apt update
sudo apt install redis-server
sudo service redis-server start
redis-cli ping
Output
PONG
⚠️

Common Pitfalls

Common mistakes when installing Redis on Windows include:

  • Trying to run Linux Redis commands directly in Windows Command Prompt without WSL.
  • Not enabling WSL before attempting to install Redis via Linux commands.
  • Using outdated or unofficial Redis Windows ports that may lack features or security updates.
  • Forgetting to start the Redis server after installation.

Always verify your Redis server is running by using redis-cli ping which should return PONG.

bash
REM Wrong: Running Linux commands in Windows CMD
wsl sudo apt install redis-server

REM Right: Use WSL first
wsl
sudo apt install redis-server
📊

Quick Reference

StepCommand/ActionDescription
1Enable WSLTurn on Windows Subsystem for Linux feature in Windows settings.
2Install Linux distroInstall Ubuntu or another Linux distro from Microsoft Store.
3Open WSL terminalLaunch the Linux terminal from Start menu.
4Update packagesRun sudo apt update to refresh package lists.
5Install RedisRun sudo apt install redis-server to install Redis.
6Start Redis serverRun sudo service redis-server start to start Redis.
7Test RedisRun redis-cli ping to check if Redis responds with PONG.

Key Takeaways

Use Windows Subsystem for Linux (WSL) to run the official Linux Redis on Windows.
Alternatively, download the Microsoft Redis port from GitHub for a native Windows version.
Always start the Redis server before trying to connect with the Redis client.
Verify installation by running redis-cli ping which should return PONG.
Avoid running Linux commands directly in Windows CMD without WSL.