postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

WSL2, Error: connect ECONNREFUSED 127.0.0.1:80 with Postman, however cUrl returns HTTP200

Open ox-rjaumain opened this issue 4 years ago • 3 comments
trafficstars

This issue follows this topic : https://community.postman.com/t/error-connect-econnrefused-127-0-0-1-443/18698

Describe the Issue

Using the Postman client under Windows 10, performing a request to an apache webserver under WSL2 returns the following error -> Error: connect ECONNREFUSED 127.0.0.1:80 However, performing the same request using curl in the Powershell terminal returns HTTP 200, which is the expected behaviour under the Postman client.

Steps to Reproduce

Under Windows 10, enable WSL. set to version 2, mount a Ubuntu-20.04 distribution. Get an apache2 server up and running on the WSL2 distribution, configure a specific vhost, ensure a request returns HTTP 200 from a web browser for instance. Run the same call under Postman client, then the error is thrown Error: connect ECONNREFUSED 127.0.0.1:80.

Screenshots or Videos

2021-05-28_12h11_38 2021-05-28_12h12_28

Environment Information

  • Platform Type:
  • Postman Version: Version 8.5.1 (8.5.1)
  • Operating System: Windows 10

Additional Context

  • Proxy settings have been disabled in Postman
  • Sent request headers have been reduced to the minimum AFAIK

ox-rjaumain avatar May 28 '21 10:05 ox-rjaumain

I added this comment to the Postman community post. Pasting it here for posterity.

Hi everyone,

It looks like the hostname is resolving to 127.0.0.1 via Postman. My guess is the URLs you're using are .local, which would require an mDNS lookup that perhaps Postman is not doing.

If that suspicion is correct, you can still use the IP address of your running server instead of the hostname. From Powershell, you should be able to run wsl hostname -I to get your IP address.

Note: Your TLS cert will show as invalid if it's pointing to the hostname. You may have to ignore SSL errors for this to work.

Hope this helps.

Best,

Kevin

kevinswiber avatar May 29 '21 00:05 kevinswiber

I was experiencing this same issue (and not with a .local domain, it was in the format <service>-local.<company-domain>; still specified in local hosts files).

I tracked it down to something screwy with IPv4 vs IPv6; I had entries for both. If I remove the IPv6 entry, it still fails. However, after removing the IPv4 entry (and re-instating the IPv6 one), it started working.

Also, a side comment on the previously mentioned workaround of using the IP directly... this would not work when you've got multiple services running locally and you're using a NGINX or similar to proxy between them with the same port (i.e. using the domain to do the routing).

EDIT: To clarify, the IPs in my host file were 127.0.0.1 and ::1; removing the 127.0.0.1 entry fixed things. However, I've since found that Chromium Edge will only work with the IPv4 entry present, so this is still problematic for me.

JoelDSmith avatar Sep 28 '21 00:09 JoelDSmith

I'm on WLS2 + Ubuntu 20 + Apache 2 + SSL + with Virtualhosts (myapp.local domain), and I got the same issue , tried the workaround mentioned in this topic, it works well. https://community.postman.com/t/error-connect-econnrefused-127-0-0-1-443/18698/12 But it would be great to have this issue fixed.

mao-aavn avatar May 05 '24 15:05 mao-aavn