Install Redis on Windows with WSL
Step-by-step guide to install Redis on Windows using WSL, with troubleshooting and next steps.
Focus: install redis on windows with wsl
So you want to use Redis — the lightning-fast in-memory data store — but you're on Windows and the official Redis binaries don't ship for your OS. Spin up a VM? Dual-boot? No. The cleanest, most developer-friendly path is Windows Subsystem for Linux (WSL). By the end of this lesson you'll have a fully functional Redis server running inside WSL, connected from both Linux and Windows, ready for caching, queues, and real-time data.
The problem this lesson solves
Redis is a first-class citizen on Linux and macOS, but the Windows port has always lagged behind. Microsoft once maintained a Tech Preview fork, but it's outdated, unsupported, and incompatible with modern Redis features (like Redis Stack and ACLs). Trying to run Redis on bare Windows leads to:
- Old versions without security patches
- No official support for Redis modules (RediSearch, RedisJSON, etc.)
- Confusing redis-server.exe vs wsl.exe workflows
- WSL solves this by giving you a genuine Linux kernel environment where Redis runs exactly as it does in production — no emulation, no compromises.
Core concept / mental model
Think of WSL as a thin virtualisation layer — not a full VM, not a container, but a lightweight Linux subsystem that shares your Windows file system and network stack. WSL 2 uses a real Linux kernel inside a managed VM, giving Redis near-native performance. The mental model:
- Windows is your host OS with cmd, PowerShell, VS Code, and GUI tools
- WSL is a guest Linux distro (usually Ubuntu) that lives in a hidden folder and boots on demand
- Redis runs inside WSL as a regular Linux process, listening on 127.0.0.1:6379
- Both sides can talk to each other: Windows apps see localhost:6379; Linux apps see the same port
Pro tip: WSL 2 is required for best Redis performance. WSL 1 uses a translation layer and can cause latency spikes. Always run
wsl --set-version <distro> 2after install.
How it works step by step
- Enable WSL on Windows — requires Windows 10 (build 19041+) or Windows 11. This installs the
wsl.exeCLI and optional Linux kernel update. - Install a Linux distribution — Ubuntu 22.04 LTS is the most common choice, available from the Microsoft Store or via
wsl --install -d Ubuntu. - Launch WSL — Ubuntu boots in seconds, giving you a full Bash shell.
- Update packages —
sudo apt update && sudo apt upgrade -yensures a fresh environment. - Install Redis — Ubuntu’s default repositories contain Redis 6.x (stable enough for learning). For the latest 7.x, add the Redis Team’s APT repository.
- Start Redis —
sudo service redis-server start(orredis-serverdirectly for foreground mode). - Test the connection —
redis-cli pingshould replyPONG. - Connect from Windows — any Windows app (Python, .NET, RedisInsight) can reach
127.0.0.1:6379.
Hands-on walkthrough
Enable WSL and install Ubuntu
Open PowerShell as Administrator and run:
# Install WSL and default Ubuntu distro
wsl --install
# Restart your machine when prompted
Restart-Computer
After reboot, Ubuntu will start automatically and ask you to create a Linux username/password. Verify WSL 2 mode:
wsl -l -v
# NAME STATE VERSION
# Ubuntu Running 2
Inside WSL: install Redis using APT
# Enter WSL if not already there
wsl ~
# Update package lists
sudo apt update
# Install Redis (this installs redis-server + redis-cli + redis-sentinel)
sudo apt install redis-server -y
# Verify version
redis-server --version
# Redis server v=6.0.16 ...
Start Redis and test
# Start the Redis server as a background service
sudo service redis-server start
# Or run interactively (Ctrl+C to stop)
redis-server --port 6379
# Test with redis-cli from another WSL terminal (or the same one)
redis-cli ping
# PONG
# Set and get a key
redis-cli set mykey "Hello from WSL!"
# OK
redis-cli get mykey
# "Hello from WSL!"
Pro tip: To make Redis start automatically when WSL boots, add
sudo service redis-server startto your~/.bashrcor use a systemd-like approach withsudo systemctl enable redis-server(only in distros that support systemd).
Connect from Windows
Open PowerShell and ping Redis from the Windows side:
# redis-cli.exe is not installed on Windows, but you can use telnet or Python
python -c "import redis; r = redis.Redis(host='localhost', port=6379); print(r.ping())"
# True (if redis-py is installed)
Or use redis-cli directly from inside WSL but run the command from Windows’ cmd:
wsl redis-cli ping
Compare options / when to choose what
| Method | Pros | Cons | Best for |
|---|---|---|---|
| WSL 2 + Ubuntu (this lesson) | Official Linux Redis, latest features, production-like environment | Requires Windows 10/11, needs WSL set up | Developers wanting real Redis |
| Docker Desktop (Windows) | Containerised, easy version switching, good isolation | Extra overhead, networking nuances, bigger disk usage | Teams already using Docker |
| Redis for Windows (MSOpenTech) | Native Windows binary, no WSL needed | Abandoned, version 3.0, no modules, security risks | Legacy projects only |
| Cloud Redis (Redis Cloud) | Zero setup, auto-scaling, fully managed | Requires internet, costs money | Production / teams without ops |
- Choose WSL 2 for local development where you need the exact same Redis as production.
- Choose Docker if you already containerise your entire stack.
- Avoid native Windows Redis unless you're stuck on an old Windows version without WSL support.
Troubleshooting & edge cases
- "WSL 2 requires an update" — download the Linux kernel update package from Microsoft’s docs (https://aka.ms/wsl2kernel).
- Redis fails to start: "Cannot open PID file" — likely a permissions issue. Run
sudo mkdir -p /var/run/redis && sudo chmod 777 /var/run/redis. - Redis starts but connection refused — check if Redis is bound to
127.0.0.1only. WSL interop works fine with default config. If usingbind 0.0.0.0, ensure firewall allows port 6379. - "redis-cli: command not found" — Redis CLI is part of
redis-tools. Install withsudo apt install redis-tools. - Auto-start doesn't work — WSL doesn't support systemd natively. Use
sudo crontab -eand add@reboot /usr/bin/redis-server /etc/redis/redis.confor usewsl --execin a Windows Task Scheduler trigger. - Port conflicts — if another service uses 6379 (rare), edit
/etc/redis/redis.confand changeport 6379to another number, then restart Redis.
What you learned & what's next
You now know how to install Redis on Windows with WSL — from enabling the subsystem to starting the server and connecting from both Linux and Windows. You understand why WSL 2 is the recommended approach and have a mental model for how Redis runs inside a Linux environment on Windows.
Key takeaways:
1. WSL 2 gives you a real Linux kernel — Redis runs as in production.
2. The redis-server and redis-cli tools work exactly like on Linux.
3. Windows apps can talk to Redis via localhost:6379 without extra configuration.
4. Avoid the deprecated native Windows port — it's insecure and outdated.
5. Auto-start Redis by adding the start command to ~/.bashrc or using systemd if your distro supports it.
Next lesson: Now that Redis is running, you'll learn Redis data types — strings, lists, sets, hashes, and sorted sets — the building blocks for caching, real-time leaderboards, and message queues.
Ready to go deeper? Install redis-py on your Windows Python environment and start sending commands right from VS Code.
Practice recap
Now that Redis is installed in WSL, open a WSL terminal and run redis-cli ping. Expect PONG. Then create a simple Python script that connects to redis.Redis(host='localhost', port=6379) and sets a key. Try running the same script from Windows PowerShell to verify cross-OS connectivity.
Common mistakes
- Using the deprecated native Windows Redis (MSOpenTech) — it's stuck on version 3.0, lacks security patches, and has no Redis Stack support.
- Forgetting to run
wsl --set-version <distro> 2after install — WSL 1 has significant networking overhead that can cause Redis latency spikes. - Editing Redis config without restarting the service: always run
sudo service redis-server restartorps aux | grep redisto verify the new config is loaded. - Binding Redis to
0.0.0.0without a firewall rule — this exposes Redis to your local network. In WSL, keepbind 127.0.0.1for security. - Assuming Redis auto-starts after WSL reboot — WSL doesn't run systemd by default. You must add
sudo service redis-server startto~/.bashrcor use Windows Task Scheduler.
Variations
- Docker Desktop + Redis Stack: Run
docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stackfor a feature-rich environment with RedisInsight GUI. - Ubuntu Pro via WSL: If you need Redis 7.x, add the Redis Team’s APT repo (
sudo add-apt-repository ppa:redislabs/redis) instead of the default Ubuntu repo. - memurai: A native Windows Redis-compatible server with a free developer edition — worth trying if you absolutely cannot use WSL.
Real-world use cases
- Caching session data for a Django app running on Windows — the app connects to Redis inside WSL via localhost, reducing DB queries by 90%.
- Real-time leaderboard for a game prototype — Redis sorted sets update scores every second; WSL provides production-like latency.
- Message queue for a .NET microservice — using Redis Streams inside WSL to decouple a Windows web API from a background worker.
Key takeaways
- WSL 2 is the recommended way to run Redis on modern Windows — it gives you the official Linux Redis with full feature parity.
- Enabling WSL requires only two PowerShell commands:
wsl --installand a reboot — no dual-boot or VM manager needed. - Redis inside WSL is accessible from Windows apps via
127.0.0.1:6379— no extra network config. - Auto-starting Redis in WSL requires a manual step — systemd is not available by default; add the start command to your shell profile.
- Avoid the deprecated native Windows Redis binary — it’s insecure, old, and unsupported.
- Use
redis-cli pingto verify the server is running before writing any application code.
Keep learning
Related tutorials, quizzes, and articles for this topic.
Discussion
Questions, corrections, and tips help everyone reading this page.
0 comments
Add a comment
No comments yet — start the thread.