Installation & Setup Windows Install

OpenClaw WSL Setup: Run Linux Agents on Windows the Right Way

WSL2 gives you full Linux performance inside Windows — and OpenClaw runs on it flawlessly. The gotchas are all in networking and autostart. This guide solves both.

TC
T. Chen
AI Systems Engineer
Feb 7, 2025 14 min read 6.4k views
Updated Feb 7, 2025
Key Takeaways
  • WSL2 is the right choice when you need Docker, Linux skills, or bash tooling alongside OpenClaw
  • Ubuntu 22.04 LTS is the most tested WSL distro for OpenClaw — use it unless you have a specific reason not to
  • Gateway networking requires finding your WSL2 IP — it changes on each WSL restart unless you use mirrored networking
  • Use a Windows Task Scheduler job to auto-start OpenClaw inside WSL on Windows login
  • Keep config files in WSL-native paths (/home/user/) not Windows mounts (/mnt/c/) for better performance

WSL2 changed Windows development permanently. Near-native Linux kernel, Docker integration, full filesystem access — and OpenClaw runs on it without modification. The challenge isn't the installation, it's getting the networking right so your Windows apps can reach the Linux gateway. This guide solves that in five minutes.

When to Use WSL vs Native Windows

Native Windows is simpler for most users. Choose WSL when you need any of these:

  • Docker containers for OpenClaw or its dependencies
  • Linux-specific OpenClaw skills that require bash, curl, or Linux binaries
  • Consistency with a Linux production environment you'll eventually deploy to
  • Local LLM inference tools like Ollama that run better on Linux

If none of these apply, use the native Windows install — it's faster to set up and has fewer networking considerations.

Enable WSL2 on Windows 11

WSL2 is built into Windows 11. Enable it with a single command in PowerShell (run as Administrator):

# Enable WSL and install Ubuntu 22.04 in one command
wsl --install -d Ubuntu-22.04

# After the install and restart, update WSL to latest
wsl --update

Windows will prompt for a restart. After the restart, Ubuntu launches and asks you to create a username and password. This is your Linux user — remember it.

💡
Enable Mirrored Networking
WSL2's default NAT networking assigns a new IP to your distro on every restart. Enable mirrored networking in Windows 11 to give your WSL2 instance a stable IP. Create or edit C:\Users\YourName\.wslconfig and add: [wsl2] on one line, networkingMode=mirrored on the next. Then run wsl --shutdown and restart WSL.

Install Node.js and OpenClaw in WSL

Inside your WSL Ubuntu terminal, install Node.js via NodeSource for the latest LTS:

# Install Node.js 20 LTS via NodeSource
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# Verify install
node --version
npm --version

# Install OpenClaw globally
npm install -g @openclaw/cli

# Verify
openclaw --version

No PATH issues on Linux — npm's global bin is already in PATH after a NodeSource install. OpenClaw is now installed and ready.

Gateway Networking: Reaching WSL from Windows

This is the part most guides skip. Your OpenClaw gateway runs inside WSL, but you want to access it from Windows browsers, Telegram webhooks, or other Windows apps. Two approaches work:

Option A: Find the WSL IP (simple, changes on restart)

# Inside WSL — get the IP
ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1

Use this IP from Windows to reach your gateway. For example, if the IP is 172.28.45.100, your gateway is at http://172.28.45.100:8080.

Option B: Port forwarding (stable)

# In PowerShell (as admin) — forward Windows localhost:8080 to WSL
$wslIp = (wsl hostname -I).Trim()
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=$wslIp

With this, http://localhost:8080 on Windows reaches your WSL gateway. Re-run after each WSL restart, or use mirrored networking from the callout above to make the IP stable.

⚠️
Don't Run OpenClaw in Both WSL and Windows
Running the OpenClaw gateway in both environments simultaneously causes port conflicts and split config state. Pick one and stick with it. If you're using WSL, disable or uninstall the native Windows instance.

Autostart OpenClaw When Windows Boots

The cleanest autostart method uses Windows Task Scheduler to trigger a WSL command on login:

  1. Open Task Scheduler (search in Start)
  2. Create Basic Task → name it "OpenClaw WSL"
  3. Trigger: When I log on
  4. Action: Start a program
  5. Program: wsl.exe
  6. Arguments: -d Ubuntu-22.04 -e bash -c "pm2 resurrect && sleep 2"
  7. Finish and check "Run whether user is logged on or not" → off (keep it user-scoped)

Inside WSL, set up PM2 first:

npm install -g pm2
pm2 start openclaw -- serve
pm2 save

Common Mistakes

The mistake that breaks WSL setups most: installing Node.js via apt without the NodeSource setup script. Ubuntu's default apt repo ships Node.js 12 — ancient, incompatible with OpenClaw. Always use the NodeSource setup script or nvm to get Node 18+.

Second mistake: storing config files in /mnt/c/ for convenience. Windows filesystem mounts in WSL have significantly worse I/O performance than the native WSL filesystem. Keep your ~/.openclaw/ directory in the Linux filesystem — symlink it to a Windows path if you need Windows access, but don't live on the mount.

Third: forgetting that WSL sleeps when no terminal is open. Without a running terminal or a task scheduler job, WSL will eventually suspend and your gateway will stop responding. Use the Task Scheduler method above to keep it alive, or consider upgrading to a proper Linux server for persistent deployments.

Frequently Asked Questions

Should I run OpenClaw on WSL or native Windows?

For most users, native Windows is simpler. Use WSL when you need Docker integration, Linux-specific skills, or bash tooling. WSL2 offers near-native Linux performance and full Docker support, making it the better choice for production-grade agent setups on Windows hardware.

Which WSL distribution works best with OpenClaw?

Ubuntu 22.04 LTS is the most tested and documented distro for OpenClaw on WSL. Ubuntu 24.04 also works. Avoid Alpine inside WSL — its musl libc can cause compatibility issues with some npm packages.

How do I access the OpenClaw gateway from Windows when running inside WSL?

Find the WSL IP with ip addr show eth0 | grep 'inet ', then use that IP from Windows. Alternatively, use netsh interface portproxy to forward Windows localhost:8080 to the WSL IP:8080, or enable mirrored networking for a stable IP.

Does Docker work with OpenClaw on WSL2?

Yes. Docker Desktop for Windows integrates with WSL2 natively. Enable Docker's WSL2 backend in Docker Desktop settings, then use docker commands inside your WSL2 terminal exactly as you would on native Linux.

How do I make OpenClaw start automatically in WSL?

Use PM2 inside WSL combined with a Windows Task Scheduler task that runs wsl.exe -e bash -c "pm2 resurrect" on login. This starts your saved PM2 process list — including OpenClaw — every time you log in to Windows.

Can OpenClaw access Windows files from WSL?

Yes. Windows drives mount at /mnt/c/, /mnt/d/, etc. Performance is better when files live in the WSL filesystem rather than the Windows mount. Keep active config files in WSL-native paths for best results.

OpenClaw on WSL2 gives you the best of both worlds — Windows hardware with Linux agent flexibility. Get mirrored networking configured first, install Node via NodeSource, and use PM2 for process management. The whole setup takes under 20 minutes and runs reliably from that point forward.

TC
T. Chen
AI Systems Engineer
T. Chen has deployed OpenClaw across Windows, Linux, and macOS environments in production settings. Specializes in cross-platform compatibility, Docker integration, and agent infrastructure that works reliably under real-world conditions.
Get Every New Guide First
One email per week. No fluff. Unsubscribe anytime.