I'm using Thunder Client on Visual Studio Code, and tried making a request to "localhost:3000".
It gave me an error
Connection was refused by the server
Any fix to this?
I'm using Thunder Client on Visual Studio Code, and tried making a request to "localhost:3000".
It gave me an error
Connection was refused by the server
Any fix to this?
Using SvelteKit, VSCode and Thunder Client
Example that didn't work for me: localhost:5173/api/posts
Solved by using [::1]:5173/api/posts
You are facing this problem because of backend you juts have to start your backend and also make sure you have install body-parser
Please use your IP address instead of localhost: ipaddress:port
.
Then, it might work. Eg. 192.168.0.1:3000
For more information see our support page comment
https://github.com/rangav/thunder-client-support/issues/251#issuecomment-874439967
But instead of using
localhost:9000
I did use the actual IP set for the computer…198.168.0.189:9000
for example, then it works.
Using Django here and sending request to
127.0.0.1:8000/
instead of
localhost:8000/
works
Make sure to use the FQDN with http:// instead of https://
That worked for me
I think I may have found the solution (at least in Node/Express), indirectly thanks to Ranga Vadhineni's answer. Since I can't explain why this happens, I will just explain my train of thought on how I figured it out.
Connection was refused by the server.
Ugh, Thunder Client was again giving me trouble requesting to localhost
, changing the request URL to 127.0.0.1
didn't help, tried to use my local IP with all that implies.
192.168.0.10
0.0.0.0
But... that didn't make much sense, and it's also a huge limitation, there has to be something going on. I tried changing Thunder's URL back to 127.0.0.1
, and it worked... huh!? How about localhost
? It worked! Eh!?
Rushed back to my serve's configuration and changed the host back to localhost
. As expected this time, Thunder got a connection refused; keep in mind that both Postman and Insomia didn't have a problem with this, only Thunder! But then again Thunder reports the problem being on the server...
Instead of using localhost
for my host in the server's configuration, I tried 127.0.0.1
... voilà...
Thunder Client can handle both 127.0.0.1
and localhost
in the URL with no problem, the issue seems to be (at least in Node/Express) in the server itself.
Simply change the server's host, so that instead of listening to localhost
, it listens to 127.0.0.1
.
If anybody can provide an explanation as to why this works, please do so, I'm at a lost here
When we open the Visual Studio Code, the remote access option is automatically activated.
To work perfectly, it will depend on where your application is running. For example, if running directly on windows, close the remote vs code connection.
Then select the option "close remote connection".
express validator
routers.post('/',[
body('name').isLength({min:3}),
body('password').isLength({min:5}),
body('email').isEmail(),
],(req,res)=>{
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
res.send(req.body);
})
To fix the issue you need to explicitly define the host name in package.json file.
"dev-server": "json-server --watch ./db.json -p 3200 -H 127.0.0.1"