Skip to content

Commit

Permalink
fix WSL "connection refused" to the fake API (#311)
Browse files Browse the repository at this point in the history
* fix WSL connection refused to the fake API

* fix WSL connection refused to the fake API

* fix WSL connection refused to the fake API
  • Loading branch information
jakecoffman authored Oct 31, 2024
1 parent 152660f commit 725b27a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func NewAPI(expected []model.Output, writer io.Writer) *API {
fakeAPIHost := "127.0.0.1"
if runtime.GOOS == "linux" {
fakeAPIHost = "0.0.0.0"
// if running on WSL, 0.0.0.0 doesn't work
if version, err := os.ReadFile("/proc/version"); err == nil && strings.Contains(string(version), "Microsoft") {
fakeAPIHost = "127.0.0.1"
}
}
if os.Getenv("FAKE_API_HOST") != "" {
fakeAPIHost = os.Getenv("FAKE_API_HOST")
Expand Down

0 comments on commit 725b27a

Please sign in to comment.