Skip to content

.wslconfig vs wsl.conf — Understanding WSL2's Two Configuration Files

Audience: Developers using WSL2 who need clarity on which config file to edit

Key Points

  • .wslconfig = VM-level control Lives on Windows side; manages memory, CPU, and network mode
  • wsl.conf = Per-distro settings Lives in Linux /etc/; manages systemd, mounts, and users
  • Same reload method Both require wsl --shutdown then restart

Decide in 1 Minute: Which File Do You Need?

When you want to change a WSL2 setting, the choice between .wslconfig and wsl.conf can be confusing.

The rule is simple. Is it a setting for the VM (virtual machine) itself, or for the Linux running inside it? To limit RAM to 4GB, use .wslconfig. To enable systemd, use wsl.conf. Their roles are completely separate.

Aspect.wslconfig/etc/wsl.conf
LocationWindows: C:\Users\<Name>\.wslconfigLinux: /etc/wsl.conf
ScopeAll distros (global)That distro only (local)
ControlsVM itself (CPU, RAM, networking)Distro behavior (mounts, systemd, user)
WSL 1 supportNo (WSL 2 only)Yes (WSL 1 and 2)

This table covers 80% of cases. Let's look at specific settings.

.wslconfig — Control the VM from Windows

.wslconfig doesn't exist by default. Create it manually at C:\Users\<UserName>\.wslconfig.

Key Settings

Write settings under the [wsl2] section.

C:\Users\<UserName>\.wslconfig
[wsl2]
memory=4GB
processors=2
swap=2GB
localhostForwarding=true
nestedVirtualization=true
KeyDefaultDescription
memory50% of physical RAMMemory allocated to the VM
processorsAll logical processorsCPU cores for the VM
swap25% of physical RAMSwap size. 0 to disable
localhostForwardingtrueExpose WSL ports on Windows localhost
networkingModeNATNetwork mode (see below)
nestedVirtualizationtrueAllow VMs inside WSL

The most common use case is RAM limiting. WSL2 takes 50% of physical memory by default — on an 8GB machine, that's 4GB claimed by WSL. Setting memory=4GB keeps the host OS responsive.

Mirrored Mode (Windows 11 22H2+)

If WSL2 networking is unstable under VPN, networkingMode=mirrored helps.

.wslconfig
[wsl2]
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

Mirrored mode mirrors Windows network interfaces directly into Linux. DNS issues under VPN and proxy environments improve significantly.

Experimental Section

Memory reclaim and VHD auto-shrink are available as experimental features.

.wslconfig
[experimental]
autoMemoryReclaim=gradual
sparseVhd=true

autoMemoryReclaim=gradual releases cached memory incrementally when idle. Effective on memory-constrained machines.

/etc/wsl.conf — Configure Each Distro from Linux

wsl.conf may not exist by default. Create or edit it with sudo nano /etc/wsl.conf.

Sections and Settings

/etc/wsl.conf
[boot]
systemd=true

[user]
default=devuser

[automount]
enabled=true
options="metadata,umask=022"

[network]
generateResolvConf=false

[interop]
enabled=true
appendWindowsPath=true
SectionKey SettingsPurpose
[boot]systemd=true, commandEnable systemd, run commands at boot
[user]default=<username>Change default login user
[automount]enabled, root, optionsWindows drive mount config
[network]generateResolvConf, generateHostsControl DNS/hosts auto-generation
[interop]enabled, appendWindowsPathWindows interop settings

The "per-distro" scope matters when you run multiple distributions. You can have different default users and systemd settings for Ubuntu and Debian.

Common Configuration Examples

Disable auto-generated DNS and use custom DNS:

/etc/wsl.conf
[network]
generateResolvConf=false

After this, create /etc/resolv.conf manually:

sudo rm /etc/resolv.conf
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf

This fixes name resolution failures under corporate DNS or VPN environments.

Change Windows drive mount point:

/etc/wsl.conf
[automount]
root=/

The default /mnt/c becomes /c. Shorter paths, but watch for compatibility with existing scripts.

How to Apply Changes

The same procedure applies regardless of which file you changed.

Run in PowerShell
wsl --shutdown

Then reopen WSL. Simply closing the terminal isn't enough — WSL background processes linger for about 8 seconds. wsl --shutdown ensures a clean stop.

To restart only a specific distro:

wsl --terminate Ubuntu

Summary

  • .wslconfig is VM-wide, wsl.conf is per-distro — remember this and you'll never mix them up
  • RAM, CPU, network mode go in .wslconfig; systemd, users, mounts go in wsl.conf
  • Both need wsl --shutdown to apply

If changes don't take effect, first make sure you ran wsl --shutdown. If it still doesn't work, check the file location. Putting .wslconfig inside Linux or wsl.conf on the Windows side is a surprisingly common mistake.