Skip to content

Commit 725b27a

Browse files
authored
fix WSL "connection refused" to the fake API (#311)
* fix WSL connection refused to the fake API * fix WSL connection refused to the fake API * fix WSL connection refused to the fake API
1 parent 152660f commit 725b27a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

internal/server/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func NewAPI(expected []model.Output, writer io.Writer) *API {
4343
fakeAPIHost := "127.0.0.1"
4444
if runtime.GOOS == "linux" {
4545
fakeAPIHost = "0.0.0.0"
46+
// if running on WSL, 0.0.0.0 doesn't work
47+
if version, err := os.ReadFile("/proc/version"); err == nil && strings.Contains(string(version), "Microsoft") {
48+
fakeAPIHost = "127.0.0.1"
49+
}
4650
}
4751
if os.Getenv("FAKE_API_HOST") != "" {
4852
fakeAPIHost = os.Getenv("FAKE_API_HOST")

0 commit comments

Comments
 (0)