A Practical WSL2 Setup: Configuration Tips I Use for Development
A few simple settings can make WSL2 much more predictable and comfortable for development. In this guide, I share the configuration I commonly use for memory, CPU, swap, systemd, networking, hosts, and file permissions.

WSL2 already works very well with its default settings, but a few adjustments can make a noticeable difference when it becomes part of your daily development environment.
For developers working with PHP, Node.js, Docker, databases, local servers, and Linux tooling, it is especially useful to understand two configuration files:
.wslconfig/etc/wsl.conf
They serve different purposes, and understanding that difference avoids a lot of confusion.
.wslconfig vs /etc/wsl.conf
The .wslconfig file controls global WSL2 settings and is stored in the Windows user profile:
C:\Users\YOUR_USER\.wslconfigThe /etc/wsl.conf file controls configuration for a specific Linux distribution:
/etc/wsl.confIn practice:
| File | Scope | Examples |
|---|---|---|
.wslconfig | Global WSL2 settings | Memory, CPU, swap, networking |
wsl.conf | Per-distribution settings | systemd, automount, hosts, user |
This distinction matters because configuration examples often mix settings from both files.
1. Limiting memory and processors
In my .wslconfig, one setting I find useful is explicitly limiting the resources available to WSL:
[wsl2]
memory=16GB
processors=8
swap=2GBThe goal is not simply to give Linux as many resources as possible.
WSL shares the host machine’s resources with Windows and other applications. Explicit limits can make the development environment more predictable, especially when several heavy applications are running at the same time.
memory
memory=16GBThis defines the memory limit for the virtual machine used by WSL2.
The right value depends on the amount of RAM available on the host and on the type of development work you do.
For example, you may have:
- an IDE;
- a browser;
- Docker;
- databases;
- AI tools;
- Linux services;
- Windows applications.
There is no universal value that works for every machine.
processors
processors=8This defines how many logical processors can be used by the WSL2 VM.
On machines with many CPU cores, setting a limit can help prevent Linux workloads from consuming every available processor.
swap
swap=2GBThis defines the amount of swap space used by WSL2.
Swap does not replace RAM, but it provides an additional layer of memory when physical memory becomes insufficient.
I prefer keeping a relatively small swap size on a development machine, although the right value depends on the workload.
2. Mirrored networking mode
Another setting I keep available, but do not always enable, is:
[wsl2]
networkingMode=mirroredThe mirrored mode changes the networking architecture used by WSL2 so that Windows network interfaces are mirrored into Linux.
According to Microsoft’s documentation, benefits include IPv6 support, improved VPN compatibility, multicast support, and direct LAN access to WSL in appropriate scenarios.
Because of that, I usually leave the option commented out:
# networkingMode=mirroredThis makes it easy to enable when needed.
The setting can be particularly interesting when working with:
- corporate VPNs;
- multiple network interfaces;
- local services that need to be reached from other devices;
- environments where the default WSL NAT networking causes limitations.
It is still worth enabling it only when your environment actually needs it.
3. Enabling systemd
This setting belongs in /etc/wsl.conf inside the Linux distribution:
[boot]
systemd=trueSystemd becomes useful when Linux services need to behave more like they would on a traditional Linux installation.
For example:
systemctl statusor:
systemctl list-unit-files --type=serviceThis can simplify environments that depend on services such as:
- Docker;
- databases;
- Redis;
- background services;
- other applications that use systemd.
After changing wsl.conf, the WSL instance usually needs to be restarted.
From Windows:
wsl --shutdownThen start the distribution again.
4. Keeping a custom /etc/hosts
Another setting I like is:
[network]
generateHosts=falseBy default, WSL can automatically generate /etc/hosts.
Disabling that behavior allows the distribution to keep its own hosts file instead.
This is useful when working with several local development domains.
For example:
127.0.0.1 app.local
127.0.0.1 api.local
127.0.0.1 admin.localThis can be useful for development environments with:
- multiple applications;
- reverse proxies;
- virtual hosts;
- Traefik;
- Apache;
- Nginx;
- custom local domains.
5. File permissions on /mnt
This is another setting that can make a difference when working with Windows files from Linux.
By default, WSL mounts Windows drives under:
/mnt/c
/mnt/dusing DrvFs.
In /etc/wsl.conf, additional mount options can be configured:
[automount]
options="metadata"The metadata option allows Linux permission metadata to be stored for Windows files mounted through WSL.
This is useful when Linux tools depend on file permissions.
6. Using umask and fmask
Another option is:
[automount]
options="metadata,umask=022,fmask=011"These masks control which permissions are removed from files and directories.
For example:
umask=022is a common configuration that usually results in directory permissions behaving similarly to:
755fmask can then be used to apply an additional mask specifically to files.
The important difference is:
umaskaffects files and directories;fmaskaffects files;dmaskcan be used specifically for directories.
These permission masks are documented by Microsoft as part of the DrvFs automount options.
One important detail
Do not create multiple [automount] sections in the same file as two different examples found online.
Use a single section:
[automount]
options="metadata,umask=022,fmask=011"Or, if you do not need the masks:
[automount]
options="metadata"These are alternatives.
7. My base configuration
When the settings are correctly split between the two files, a configuration close to what I use looks like this.
%UserProfile%\.wslconfig
[wsl2]
memory=16GB
processors=8
swap=2GB
# Enable when it makes sense for your networking environment
# networkingMode=mirrored/etc/wsl.conf
[boot]
systemd=true
[network]
generateHosts=false
[automount]
options="metadata,umask=022,fmask=011"Keeping these files separate makes it much easier to understand which settings are global WSL2 options and which settings belong to a specific Linux distribution.
8. An important performance detail
There is another setting that I consider even more important than many .wslconfig options: where project files are stored.
When most development tools run inside Linux, I prefer keeping projects in the Linux filesystem:
/home/fernando/projectsinstead of:
/mnt/c/Users/Fernando/projectsMicrosoft recommends storing files on the same operating system as the tools that access them most frequently.
For example, Linux tools such as:
git
npm
composer
php
makeusually perform better when the project is stored in the Linux filesystem.
The difference becomes particularly noticeable in projects with many files, such as:
node_modules
vendor
.git
cache
buildWhen I need to access the files from Windows Explorer, I can simply run:
explorer.exe .That lets me keep the files inside the Linux filesystem without giving up Windows integration.
9. Applying configuration changes
After changing .wslconfig or /etc/wsl.conf, simply closing the terminal window may not be enough.
A practical way to restart WSL is:
wsl --shutdownThen:
wslYou can also check whether any distributions are still running:
wsl --list --runningThis matters because configuration changes only take effect after the WSL instance has fully stopped and restarted.
10. Checking the configuration
After restarting, I like to quickly verify the environment.
Memory
free -hCPUs
nprocSystemd
systemctl is-system-runningMounts
mount | grep /mntInstalled distributions
From Windows:
wsl --list --verboseWSL version
wsl --versionThese checks help distinguish configuration problems from issues related to the WSL version itself.
11. What is actually worth configuring?
There is no universal WSL2 configuration.
My approach is to start with the minimum required settings and add more only when the development environment actually needs them.
I usually think about four categories.
Resources
memory=16GB
processors=8
swap=2GBLinux services
[boot]
systemd=trueNetworking
[network]
generateHosts=falseor:
networkingMode=mirroredFiles
[automount]
options="metadata,umask=022,fmask=011"The goal is not to have the largest possible configuration file.
The goal is to have a predictable development environment.
Conclusion
WSL2 works very well with its defaults, but understanding its configuration files gives you much more control over the environment.
For me, the most useful areas are:
- controlling how much CPU and memory WSL can use;
- enabling
systemdwhen Linux services need it; - controlling how
/etc/hostsis managed; - adjusting permissions for Windows drives mounted inside Linux;
- enabling
mirrorednetworking when the default NAT architecture is not enough; - keeping projects in the Linux filesystem when the main development tools run inside WSL.
More importantly, the goal should not be to copy someone else’s configuration blindly.
The best .wslconfig is the one that matches your machine and your development workflow.