TutorialWindowsWSLMarch 10, 2026·8 min read

How to Run OpenClaw on Windows with WSL: Step-by-Step Guide

OpenClaw is built for Linux and macOS, but most developers run Windows. The good news is that WSL2 (Windows Subsystem for Linux) gives you a full Linux environment inside Windows with near-native performance. This guide walks you through every step from enabling WSL to running your first OpenClaw agent, with tips specific to Windows users along the way.

Why WSL for OpenClaw

OpenClaw relies on Unix shell scripts, file system watchers, and process management tools that do not exist natively on Windows. Previous workarounds like Git Bash or Cygwin only partially work and break on gateway startup, agent file watching, and npm postinstall scripts. WSL2 solves all of this by running a real Linux kernel alongside Windows.

With WSL2, you get full compatibility with every OpenClaw feature including the gateway daemon, Telegram and Discord channel adapters, file-based agent configuration, and Ollama for local models. Performance is nearly identical to running on a native Linux machine because WSL2 uses hardware virtualization rather than translation layers.

Note: WSL1 does not work reliably with OpenClaw. The filesystem translation layer in WSL1 causes inotify failures that break agent hot reload and HEARTBEAT.md file watching. Always use WSL2.

Prerequisites

Before you start, make sure your system meets these requirements:

RequirementDetails
Windows VersionWindows 10 (build 19041+) or Windows 11
RAM8 GB minimum, 16 GB recommended
Disk SpaceAt least 5 GB free (more if using Ollama for local models)
VirtualizationHardware virtualization enabled in BIOS (VT-x / AMD-V)
TerminalWindows Terminal recommended (free from Microsoft Store)

To check your Windows build number, press Win + R, type winver, and press Enter. The dialog shows your version and build number.

Step 1: Install WSL2

Microsoft has simplified WSL installation to a single command. Open PowerShell as Administrator (right-click the Start button and select "Terminal (Admin)" or "PowerShell (Admin)") and run:

PowerShell (Administrator)
# Install WSL with Ubuntu as the default distribution
wsl --install

# If WSL is already installed, make sure you're on version 2
wsl --set-default-version 2

# Verify the installation
wsl --version

After the command completes, restart your computer. Windows will finish setting up the Linux kernel and the Virtual Machine Platform. This restart is required and cannot be skipped.

Troubleshooting: If you get error 0x80370102, virtualization is not enabled in your BIOS. Restart your computer, enter BIOS setup (usually F2 or Del during boot), find the virtualization setting (Intel VT-x or AMD SVM), enable it, and save.

Step 2: Set Up Ubuntu

After the restart, Ubuntu will launch automatically and ask you to create a username and password. This is your Linux user account inside WSL. It is separate from your Windows account.

Ubuntu terminal (first launch)
# Ubuntu will prompt for username and password on first launch
# Choose a simple username (lowercase, no spaces)

# Once inside Ubuntu, update the package list
sudo apt update && sudo apt upgrade -y

# Install essential build tools
sudo apt install -y build-essential git curl wget unzip

If Ubuntu did not launch automatically, open Windows Terminal and click the dropdown arrow next to the tab bar. You should see "Ubuntu" listed as a profile. If not, install it manually:

# List available distributions
wsl --list --online

# Install Ubuntu 24.04 LTS
wsl --install -d Ubuntu-24.04

# Set it as the default WSL distribution
wsl --set-default Ubuntu-24.04

Step 3: Install Node.js via nvm

OpenClaw requires Node.js 18 or higher. The best way to manage Node.js versions on Linux is nvm (Node Version Manager). Do not use sudo apt install nodejs because Ubuntu's default repositories often ship outdated versions.

Inside WSL Ubuntu terminal
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Reload your shell profile
source ~/.bashrc

# Install the latest LTS version of Node.js
nvm install --lts

# Verify the installation
node --version    # Should show v22.x or higher
npm --version     # Should show v10.x or higher

# Set as default
nvm alias default node

If nvm is not found after installation, close and reopen your terminal or run source ~/.bashrc again. The nvm install script adds lines to your .bashrc that only take effect in new shell sessions.

Step 4: Install OpenClaw

With Node.js ready, install OpenClaw globally using npm:

# Install OpenClaw globally
npm install -g openclaw

# Verify it installed correctly
openclaw --version

# Initialize a new project directory
mkdir ~/my-agents && cd ~/my-agents
openclaw init

# You should see:
# Initialized OpenClaw project in /home/your-username/my-agents
# Created: SOUL.md, config.yaml

Important: Do not use sudo npm install -g. If you get EACCES permission errors, fix your npm prefix instead: mkdir ~/.npm-global && npm config set prefix '~/.npm-global' and add export PATH=~/.npm-global/bin:$PATH to your ~/.bashrc.

Step 5: Configure Your First Agent

OpenClaw agents are defined by SOUL.md files. This is a markdown file that describes who the agent is, what it does, and how it behaves. Create your first agent:

~/my-agents/SOUL.md
# Project Manager Agent

## Identity
You are a project manager AI assistant. You help track tasks,
summarize progress, and flag blockers.

## Rules
- Always respond in English
- Keep responses under 200 words unless asked for detail
- Use bullet points for lists
- Never make up data — say "I don't have that information" if unsure

## Skills
- Summarize daily standups
- Track task completion across team members
- Flag overdue items
- Generate weekly progress reports

## Channels
- Telegram
- Slack

Next, configure your model provider. OpenClaw supports Claude, GPT-4, local models via Ollama, and others:

# Set your model provider (choose one)

# Option A: Anthropic Claude
openclaw config set provider anthropic
openclaw config set provider.anthropic.apikey YOUR_ANTHROPIC_KEY

# Option B: OpenAI GPT-4
openclaw config set provider openai
openclaw config set provider.openai.apikey YOUR_OPENAI_KEY

# Option C: Local model with Ollama (free, no API key needed)
openclaw config set provider ollama
openclaw config set provider.ollama.model qwen3.5:14b
openclaw config set provider.ollama.host http://localhost:11434

# Register the agent
openclaw agents add pm --soul ./SOUL.md

# Verify
openclaw agents list

Step 6: Run the Gateway

The gateway is the process that keeps your agents alive and connected to their channels (Telegram, Slack, Discord, etc.). Start it from your project directory:

# Start the gateway
openclaw gateway start

# You should see output like:
# [gateway] starting on port 18789
# [agent:pm] loaded SOUL.md (5 rules, 4 skills)
# [gateway] ready — 1 agent active

# To run in the background (detached)
nohup openclaw gateway start > ~/openclaw.log 2>&1 &

# Check gateway status
openclaw gateway status

# View real-time logs
openclaw gateway logs --follow

# Send a test message to your agent
openclaw agent --agent pm --message "What can you do?"

If the gateway starts successfully, your agent is running. You can now connect channels like Telegram or Discord, or interact with the agent directly through the CLI.

Windows Terminal Tips

Windows Terminal is the best way to work with WSL. Here are some tips to make your workflow smoother:

Set Ubuntu as Default Profile

Open Windows Terminal Settings (Ctrl + ,). Under "Startup," change the default profile to Ubuntu. Now every new tab opens directly in your WSL environment instead of PowerShell.

Split Panes for Logs and Commands

Press Alt + Shift + D to split the terminal into two panes. Use one pane for openclaw gateway logs --follow and the other for running commands. This gives you a real-time view of what your agents are doing while you interact with them.

Custom Starting Directory

In Terminal Settings, edit the Ubuntu profile and set the starting directory to your OpenClaw project:

// In Windows Terminal settings.json
{
  "name": "Ubuntu",
  "source": "Windows.Terminal.Wsl",
  "startingDirectory": "//wsl$/Ubuntu/home/your-username/my-agents"
}

File Access Between Windows and WSL

One of the most common questions from Windows users is how to access files between the two environments. WSL2 provides bidirectional access, but performance depends on where the files live.

# Access Windows files from WSL
# Your C: drive is mounted at /mnt/c
ls /mnt/c/Users/YourName/Documents

# Access WSL files from Windows
# Open File Explorer and navigate to:
# \\wsl$\Ubuntu\home\your-username\my-agents

# Open current WSL directory in Windows Explorer
explorer.exe .

# Open a WSL file in VS Code (with WSL extension installed)
code ~/my-agents/SOUL.md

Performance tip: Keep your OpenClaw project files inside the WSL filesystem (under /home/your-username/), not on the mounted Windows drive (/mnt/c/). File operations on /mnt/c are 3-5x slower because WSL has to translate between the Linux and Windows filesystem layers. This affects agent startup time, SOUL.md reloading, and gateway log writing.

Running OpenClaw at Startup

If you want your agents running as soon as your computer boots, you have two options depending on your Windows version.

Option A: Windows Task Scheduler

This works on both Windows 10 and 11. Create a startup script inside WSL first:

~/start-openclaw.sh
#!/bin/bash
# start-openclaw.sh — launch OpenClaw gateway on boot

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

cd ~/my-agents
nohup openclaw gateway start > ~/openclaw.log 2>&1 &
echo "OpenClaw gateway started at $(date)" >> ~/openclaw-boot.log
PowerShell — create a scheduled task
# Make the script executable
wsl chmod +x ~/start-openclaw.sh

# Create a Windows Task Scheduler entry
# Open Task Scheduler > Create Basic Task
# Trigger: "When the computer starts" or "When I log on"
# Action: Start a program
# Program: wsl
# Arguments: -d Ubuntu -- /home/your-username/start-openclaw.sh

Option B: systemd in WSL2 (Windows 11)

Windows 11 (22H2 and later) supports systemd inside WSL2. This is the cleanest approach for running services:

# Enable systemd in WSL (edit /etc/wsl.conf)
sudo tee /etc/wsl.conf > /dev/null << 'EOF'
[boot]
systemd=true
EOF

# Restart WSL from PowerShell
# wsl --shutdown
# Then reopen Ubuntu

# Create a systemd service file
sudo tee /etc/systemd/system/openclaw.service > /dev/null << 'EOF'
[Unit]
Description=OpenClaw Gateway
After=network.target

[Service]
Type=simple
User=your-username
WorkingDirectory=/home/your-username/my-agents
ExecStart=/home/your-username/.nvm/versions/node/v22.12.0/bin/node /home/your-username/.nvm/versions/node/v22.12.0/bin/openclaw gateway start
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

# Enable and start the service
sudo systemctl enable openclaw
sudo systemctl start openclaw

# Check status
sudo systemctl status openclaw

Troubleshooting Common Issues

Here are the most frequent problems Windows users run into when setting up OpenClaw with WSL, along with their fixes.

"command not found: openclaw" After Install

This means the npm global bin directory is not in your PATH. Check where npm installs global packages and add it:

# Find the npm global bin path
npm config get prefix
# Usually: /home/your-username/.nvm/versions/node/v22.x.x

# Verify openclaw is there
ls $(npm config get prefix)/bin/openclaw

# If you used a custom prefix, add it to PATH
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Gateway Port Already in Use

The default gateway port is 18789. If something else is using it, or a previous gateway instance did not shut down cleanly:

# Find what's using port 18789
lsof -i :18789

# Kill the stale process
kill -9 $(lsof -t -i :18789)

# Or start the gateway on a different port
openclaw gateway start --port 18790

WSL2 Network/DNS Issues

Sometimes WSL2 loses network connectivity or DNS resolution breaks after sleep/resume cycles. This prevents the gateway from reaching API providers:

# Quick fix: restart WSL networking
# From PowerShell (not WSL):
wsl --shutdown
# Then reopen Ubuntu

# Permanent DNS fix: use Google DNS
sudo tee /etc/wsl.conf > /dev/null << 'EOF'
[network]
generateResolvConf = false

[boot]
systemd=true
EOF

sudo rm /etc/resolv.conf
sudo tee /etc/resolv.conf > /dev/null << 'EOF'
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

# Prevent Windows from overwriting resolv.conf
sudo chattr +i /etc/resolv.conf

High Memory Usage

WSL2 can consume a lot of RAM over time. Limit it with a .wslconfig file in your Windows user directory:

# Create or edit C:\Users\YourName\.wslconfig

[wsl2]
memory=4GB
processors=2
swap=2GB

# After saving, restart WSL from PowerShell:
wsl --shutdown

File Watchers Not Working (ENOSPC)

If OpenClaw reports that it cannot watch for file changes, you have hit the inotify limit. This affects SOUL.md hot reloading and HEARTBEAT.md scheduling:

# Increase the inotify watch limit
echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

# Verify
cat /proc/sys/fs/inotify/max_user_watches
# Should show 524288

Skip Windows Setup with CrewClaw

Setting up WSL, Node.js, and OpenClaw takes time, and keeping everything running reliably on Windows requires ongoing maintenance. If you want an OpenClaw agent running without managing infrastructure, CrewClaw handles the entire setup for you.

With CrewClaw, you pick an agent template, customize the SOUL.md in a visual builder, and get a complete deploy package with Docker, configuration files, and deployment scripts. No WSL, no terminal commands, no port conflicts. It works on any operating system because you get a pre-built package ready to deploy anywhere.

For Windows users who want agents running today without spending an hour on setup, CrewClaw is the fastest path. For those who enjoy the hands-on approach and want full control over their environment, the WSL setup above gives you everything you need.

Related Guides

Frequently Asked Questions

Can I run OpenClaw directly on Windows without WSL?

OpenClaw requires a Unix-like environment for its gateway and agent system. Windows does not natively support the shell scripts, file watchers, and process management that OpenClaw relies on. WSL2 provides a full Linux kernel inside Windows, which gives you complete compatibility without dual-booting or using a virtual machine. It is the officially recommended way to run OpenClaw on Windows.

Does WSL2 affect my Windows performance?

WSL2 runs a lightweight virtual machine managed by Hyper-V. It typically uses 1-2 GB of RAM at idle and scales up based on workload. For most machines with 8 GB or more of RAM, the impact is negligible. You can limit WSL2 memory usage by creating a .wslconfig file in your Windows user directory with a memory limit like 'memory=4GB'. The CPU overhead is minimal since WSL2 uses the actual hardware, not emulation.

How do I access my OpenClaw files from Windows?

WSL2 file systems are accessible from Windows Explorer at the path \\wsl$\Ubuntu\home\your-username. You can also type 'explorer.exe .' from inside a WSL terminal to open the current directory in Windows Explorer. For best performance, keep your OpenClaw project files inside the WSL file system (under /home) rather than on the Windows side (under /mnt/c). Accessing files across the boundary is slower due to the 9P protocol translation layer.

Can I use VS Code with OpenClaw running in WSL?

Yes. Install the 'WSL' extension in VS Code (formerly called 'Remote - WSL'). Then open a WSL terminal and run 'code .' in your OpenClaw project directory. VS Code will open with full IntelliSense, terminal access, and file editing inside the WSL environment. This is the recommended development setup for Windows users working with OpenClaw.

Why does OpenClaw fail to install inside WSL with permission errors?

Permission errors during npm install usually happen when the global npm directory is owned by root. Fix this by configuring npm to use a user-level directory: run 'mkdir ~/.npm-global && npm config set prefix ~/.npm-global' then add 'export PATH=~/.npm-global/bin:$PATH' to your .bashrc. Reload with 'source ~/.bashrc' and retry the install. Never use sudo with npm install -g inside WSL.

How do I make OpenClaw start automatically when Windows boots?

Create a startup script in WSL that launches the gateway, then configure Windows Task Scheduler to run 'wsl -d Ubuntu -- /home/your-username/start-openclaw.sh' at logon. Alternatively, add the gateway start command to your .bashrc so it runs every time you open a WSL terminal. For production setups, use systemd inside WSL2 (supported since Windows 11 22H2) to manage the gateway as a proper service with auto-restart on failure.

Skip the Setup. Get Your AI Employee.

Pick a template, customize in the visual builder, and get a complete deploy package. No WSL, no terminal, no Docker debugging. Works on Windows, Mac, and Linux.

Deploy a Ready-Made AI Agent

Skip the setup. Pick a template and deploy in 60 seconds.

Get a Working AI Employee

Pick a role. Your AI employee starts working in 60 seconds. WhatsApp, Telegram, Slack & Discord. No setup required.

Get Your AI Employee
One-time payment Own the code Money-back guarantee