Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Laravel Sail pages take seconds to load on Windows with WSL2

ErrorIs Laravel really this slow?

Short answer

On Windows, Laravel Sail is slow when the project lives on the Windows drive (under /mnt/c) and Docker bind-mounts it into the container. Move the project into the WSL Linux filesystem and open it from there. Then check the memory and CPU limits given to WSL.

  • Applies to Windows 11, WSL2, Docker Desktop, Laravel Sail
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the current folder from the WSL shell. A path that starts with /mnt/c means the project is on the Windows drive.

    pwd
  2. 2Match what you see, then jump to its fix

    1. 1pwd shows /mnt/c/Users/... The project is stored on the Windows filesystemFix
    2. 2Hot reload or file watchers in the container do not notice edits.File-change watching does not work from the Windows driveFix
    3. 3The first fix helped little, and the machine is short on memory when containers run.WSL has too little memory or CPUFix

What does the error look like?

  • Is Laravel really this slow?
  • pwd prints a path that starts with /mnt/c

Cause 1 of 3

The project is stored on the Windows filesystem

1Check

Microsoft says the fastest place for files used from a Linux shell is the WSL file system, for example /home/<user>/Project, and not /mnt/c. Docker says the same about bind mounts: performance is much higher from the Linux filesystem.

pwd
ls -ld ~

2Fix

Copy the project into your Linux home directory and run Sail from there. Open it in your editor through WSL.

cp -r /mnt/c/Users/me/my-app ~/my-app
cd ~/my-app
./vendor/bin/sail up -d

3Verify

Reload the page and compare. You can browse the Linux files from Windows at \\wsl$.

explorer.exe .

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 3

File-change watching does not work from the Windows drive

1Check

Docker documents that containers only get inotify file-change events when the source files are on the Linux filesystem.

pwd

2Fix

Keep the project and everything bind-mounted into the container in the Linux filesystem.

# store the project under ~/ and mount ~/my-app into the container, not /mnt/c/...

3Verify

Edit a file and confirm the watcher reacts.

./vendor/bin/sail npm run dev

Confirmed by docs.docker.com

Did this fix it?

Cause 3 of 3

WSL has too little memory or CPU

1Check

Docker notes that the memory, CPU and swap given to the WSL 2 virtual machine are set in .wslconfig.

free -h

2Fix

Adjust the limits in .wslconfig using the options in Microsoft's WSL configuration guide, then restart WSL.

# edit .wslconfig as described in Microsoft's WSL configuration guide, then restart WSL

3Verify

Start Sail again and watch the response time.

./vendor/bin/sail up -d

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Create new Laravel projects inside the WSL home folder from the start.
  • Run composer, artisan and npm through sail so they use the container's tools.
  • Treat /mnt/c paths as a sign the project is in the wrong place for Docker work.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

composer require laravel/horizon fails: ext-pcntl is missing

laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system

Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.

3 causes, each with a fix

Back end

sail up fails with a permission error

WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied

A permission error from sail up has three documented sources on Linux: Docker Desktop is using the wrong context, files inside the container are not writable by the container user, or Docker's own config folder is owned by root from an earlier sudo run.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.