WSL icon indicating copy to clipboard operation
WSL copied to clipboard

IIS reports “404 Not Found” error for files in directories created in WLS Bash

Open knee-cola opened this issue 8 years ago • 6 comments

  • Your Windows build number: 10.0.17134.48

  • What you're doing and what's happening: after the most recent update Win10 update (1803) IIS started reporting error "404 Not Found" when serving files located in directories created from WLS bash (Ubuntu).
    IIS does list the content of the folder (via Directory Browsing), but when asked for a file located in that directory it reports 404 Not Found.

  • What's wrong / what should be happening instead: IIS should serve the files without problem ... as it did before the update.

Reproducing the error

Install IIS on you Win10 machine (make sure to select Directory Browsing), and make sure the default website works.

In Bash do the following:

$ mkdir /mnt/c/inetpub/wwwroot/xyz

$ echo this is a test > /mnt/c/inetpub/wwwroot/xyz/test.txt

Try accessing the directory in a web browser via http://localhost/xyz/

The browser should list all the files contained within the xyz directory. Something like the following:

localhost - /xyz/

[To Parent Directory]

 5/18/2018  2:10 PM           15 test.txt

Now try accessing the file from the web browser http://localhost/xyz/test.txt

IIS will respond with HTTP Error 404.0 - Not Found and Error Code 0x80070002

knee-cola avatar May 18 '18 11:05 knee-cola

This problem was caused by a changed introduced in Win build 17110, which made all new directories created in Bash to be case-sensitive (NTFS case-sensitive flag is set to enabled).

If the flag is set for a directory can be checked via CMD:

fsutil file queryCaseSensitiveInfo C:\interpub\wwwroot\xyz

For some reason IIS 10.0 has problems accessing a directory if this flag set to enabled.

The problem can be fixed by configuring WSL not to set this flag to enabled by default. This can be done by editing the /etc/wsl.conf and adding case=false to the options list:

[automount]
options="case=off"

knee-cola avatar May 18 '18 13:05 knee-cola

Recommend submitting a bug with the IIS team to support the feature.

WSLUser avatar May 18 '18 13:05 WSLUser

Will do! Thanks!

knee-cola avatar May 18 '18 13:05 knee-cola

The default mount option has been changed to case=off as of Insider Build 17704

Brian-Perkins avatar Jun 28 '18 01:06 Brian-Perkins

Hey @knee-cola , I've just got this annoying error (via gulp jobs triggered in WSL that create some html files in windows) and unfortunately your solution didnt work for me. I created wsl.conf in /etc folder both in windows (via git bash in windows) and in WSL itself. Neither worked for me; still the same error. I wonder if u have any workarounds. (I would not like to download windows insider program, its so buggy)

  • windows 10 // 1803 v17134.286
  • Ubuntu 18.04.1 LTS bionic

emrecamasuvi avatar Sep 24 '18 13:09 emrecamasuvi

Hi @emrecamasuvi!

The solution described above works only for folders created after the fix is applied. Anything created before should keep suffering from the same problem.

Try checking if the flag was set for folders created by the gulp job via:

fsutil file queryCaseSensitiveInfo C:\interpub\wwwroot\xyz

If the case-sensitivity is enabled, you can try:

  • modifying the flag for each of the folders by gulp (i.e. fsutil.exe file setCaseSensitiveInfo C:\interpub\wwwroot\xyz\ disable)
  • deleting all the folders in question and re-running the gulp job

knee-cola avatar Sep 24 '18 15:09 knee-cola