Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: FileServer on WSL fails with wget and curl for files over ~4MB #27128

upsampled opened this issue Aug 21, 2018 · 2 comments


None yet
3 participants
Copy link

commented Aug 21, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10.3 linux/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build493773858=/tmp/go-build -gno-record-gcc-switches"

using WSL

Ran the same test on a CentOS Machine and I did not see this problem

What did you do?

Attempted to server files via HTTP that an application using curl can download.

package main

import (

func main() {
        fs := http.FileServer(http.Dir("./"))
        http.Handle("/repo/", http.StripPrefix("/repo/", fs))

        http.ListenAndServe(":80", nil)

What did you expect to see?

Curl to download the files.

What did you see instead?

The file server worked for file that were roughly less than 5M, but failed for larger files with curl error 18. The curl command line tool also reproduces this error:

curl http://<IP>/repo/<FILE> --output <FILE>
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                    Dload  Upload   Total   Spent     Left  Speed
 56 7257k   56 4096k    0     0      4970k      0       0:00:01 --:--:--  0:00:01 4970k
curl: (18) transfer closed with 3237034 bytes remaining to read

Wget (busybox version) also has the same problem:

wget http://<IP>/repo/<FILE> -O <FILE>
Connecting to <IP> (<IP>:80)
pa-config-1-r0.corte   6% |**********                                                      |   460k  0:00:14 ETA
<STOPS and the file is only ~4M>

However using pythons web server, wget and curl both work
sudo python3 -m http.server 80


This comment has been minimized.

Copy link

commented Aug 22, 2018

The WSL team want you to file bugs to them about any differences from actual Linux.

We generally don't investigate these things, or only do some when it appears we might be violating Linux or POSIX APIs in undocumented ways, or do so out of curiosity.

But please file a WSL bug and link it here.

We probably won't be investigating this. It's WSL's job to act like Linux and they don't want projects treating them like its own port.


This comment has been minimized.

Copy link

commented Jun 18, 2019

i run into the same issue and while debugging it i saw that CopyN in the fileserver returns EOF early:
(changing that line to readall and write works just fine if you need a quick workaround)

@bradfitz i wondered if the ignored error could be checked and logged to make easier to debug issues happening there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.