POST to localhost

Hi,
May I ask that, if I am trying to do a POST do a random port e.g. https://localhost:5001/api/TodoItems/1. and In ā€œBodyā€ is just a simple, raw, JSon, then;
{

ā€œnameā€:ā€œwalk dogā€,

ā€œisCompleteā€:true

}
However, no matter what port I am choosing, I always get ā€œError: connect ECONNREFUSEDā€
I already disabled SSL certificate verification and unticked using system proxy. Is there a way for me to just POST to my localhost

Do you have a webserver configured locally, and listening at that port? Is there a reason you are using 5001 over just 80 or 443? Otherwise I recommend staying in common port territory.

Thank you for replying.
no, I have not made any webserver configuration locally. May I know what is the range of the common port territory too?
So basically I have to do a local webserver configuration and uses common port?

Hey @zhangmingcheng28 Yes! You need to have a webserver that is listening on localhost over the port number you are trying to access.

Once you send the request via Postman to that server, it will (or should) process your request and then return a response.

Here is a tutorial using NodeJS to create a simple web-server running locally: https://nodejs.org/en/knowledge/HTTP/servers/how-to-create-a-HTTP-server/

If you prefer any other language, search online to find out how to create a web-server using that programming language.

1 Like

Hi, I am having difficulties while connecting to localhost. On sending a POST request, I am having Could not send request in Postman response.

:5001 is a kestrel port common to .net core apps. and web apis running in debug mode in VS.

Hey, Iā€™m trying to send post request to my localhost:4000 server & I already have my node server running on 4000.
But Iā€™m continuously getting the following error:
Error: Client network socket disconnected before secure TLS connection was established

Please suggest how to fix this.

Hey @theking003ks :wave: Welcome to the community.

Do post what troubleshooting you have done till now, it helps others to provide better help.
Also, instead of using an existing thread, try creating a new thread in appropriate section. (Unless your problem is exactly the same, which in this case it doesnā€™t look to be the case)

From what I see you are trying to access localhost over TLS (https) and most likely you do not have the certificates setup on your server. Try accessing your server over http, and things should work fine: http://localhost:4000

Assuming this is a plain vanilla test node server, highly likely https isnā€™t setup.

1 Like

Iā€™m also new to Postman myself, but to use it from the browser to access a locally-running server, you need to have the Postman Desktop Agent installed. See the official support article for more help, and this article from the official Postman blog to understand why you need it.

Being a newbie myself, I was confusing the Postman Desktop App with the Postman Desktop Agent. Similar names, but completely different apps (and concepts)!

2 Likes

you are using, https://
with local host, try http://. instead.

I was using port 5000 and getting the same error. It worked for me, turning off ā€˜Use the system proxyā€™ and use the Proxy Type HTTP only as I donā€™t have SSL certificate.

2 Likes

This fixed it for me. Thank you.

1 Like

Thanks, work fine for me