Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.21k stars 433 forks source link

Connection is being rejected for localhost #523

Open heneds opened 4 years ago

heneds commented 4 years ago

Expectation: If I specify "localhost" in the host address the request should not change to "127.0.0.1".

Some web servers (in this case II Express) do not recognize 127.0.0.1. The server gets the request but is not be able to map against the correct web application.

Symptom:

Connection is being rejected. The service isn’t running on the server, or incorrect proxy settings in vscode, or a firewall is blocking requests. Details: RequestError: connect ECONNREFUSED 127.0.0.1:63353.

See also #122

Steps to Reproduce:

  1. Run a web app from Visual Studio using IIS Express and http
  2. Any REST Client request to localhost will get the response ECONNREFUSED 127.0.0.1

2020-02-12 13_47_05-Home page - WebApplication1

A-make commented 1 year ago

I was having the same issue with REST Client. So I checked the address my webserver was listening on using

netstat -aon

There I found that my server was binding to [::1]. So after replacing localhost with [::1]

GET http://[::1]:12345

REST Client is now able to contact my server.

Pestilence01 commented 1 year ago

I was having the same issue with REST Client. So I checked the address my webserver was listening on using

netstat -aon

There I found that my server was binding to [::1]. So after replacing localhost with [::1]

GET http://[::1]:12345

REST Client is now able to contact my server.

You are a life saver. This issue has been bugging me for days now. Your solution is the ONLY one that was able to fix the issue. Thank you from the bottom of my heart.

Josimar-Bezerra commented 1 year ago

I was having the same issue with REST Client. So I checked the address my webserver was listening on using

netstat -aon

There I found that my server was binding to [::1]. So after replacing localhost with [::1]

GET http://[::1]:12345

REST Client is now able to contact my server.

Thank you so much for sharing your solution. I've been trying to find one that works for my situation and this one has gotten the job done.

JakaiXu commented 1 year ago

I was having the same issue with REST Client. So I checked the address my webserver was listening on using

netstat -aon There I found that my server was binding to [::1]. So after replacing localhost with [::1]

GET http://[::1]:12345 REST Client is now able to contact my server.

this solution works for me, thanks "A-make" shared this.

Aashim-Limbu commented 1 year ago

Previously i ran into this trouble while runing the json server Although i had my server running on i was constantly getting an error due to TCP [::1]:3001 [::]:0 LISTENING the solution is that I simply add the host to --host 0.0.0.0 in the script. made sure that it bind with 0.0.0.:3001: TCP 0.0.0.0:3001 0.0.0.0:0 LISTENING then boom it start working

qtopsoft commented 1 year ago

I am having bit weired issue, tomcat is rejecting fetch calls to node from client machine however, postman returns data to same calls from same client. everything works fine on server machine. cant figure out what is the issue with tomcat

leandrodemirandamauricio commented 11 months ago

Previously i ran into this trouble while runing the json server Although i had my server running on i was constantly getting an error due to TCP [::1]:3001 [::]:0 LISTENING the solution is that I simply add the host to --host 0.0.0.0 in the script. made sure that it bind with 0.0.0.:3001: TCP 0.0.0.0:3001 0.0.0.0:0 LISTENING then boom it start working

Hi @Aashim-limbu , thanks for your answer. It resolved my problem.

Could you explain why it does not work only when the request is made inside VS Code using Rest Client?

I realize that Mac OS turns localhost into 127.0.0.1 and due this, the request fails. But why is the request successful when made using Postman or directly on browser?

Using npm json-server (just installed and run json-server --watch db.json) Mac OS Monterey 12.6.9 VS Code 1.83.0 Rest Client v0.25.1 cat /etc/hosts: '## '# Host Database '# '# localhost is used to configure the loopback interface '# when the system is booting. Do not change this entry. '## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost '# Added by Docker Desktop '# To allow the same kube context to work on the host and the container: 127.0.0.1 kubernetes.docker.internal '# End of section

There is no http.proxy VS Code settings. Thanks a lot!

slawko commented 9 months ago

I'm getting the same error in VSC when trying to access json-server launched on my computer, but adding "--host 0.0.0.0" or "--host 127.0.0.1" to the json-server command fixed they issue. Yay! Thanks @Aashim-limbu!

Aashim-Limbu commented 9 months ago

@slawko I'm glad I could be of help .Hope you enjoy your journey