HttpRequestException:An error occurred while sending the request. WebException
HttpRequestException:An error occurred while sending the request. WebException:Unable to connect to the remote server SocketException:No connection could be made because the target machine actively refused it
Please let me know what could be the solution, I was trying to hit the local host only.
8 Replies
Could be a number of things, and you haven't given enough details.
1) What endpoint are you trying to hit? Is this an API you're building?
2) If this is your own api, what do your controller routes look like?
3) What is the url you are using when making this request?
yes, it is an api, runnning 48843 port
it is used to work
I don't directly invoke it
it is using the change notifications
using the graph api
i am trying to create a subscription using graphclient
it internally makes a call to our api which is a webhook event
the graphclient is throwing the exception
await _graphClient
.Subscriptions
.PostAsync(sub);
What is the endpoint it is trying to hit? Because that exception makes it seem like it is hitting the wrong port locally.
no, i tried the same
https://localhost:48843
Has your project been properly configured to use https locally?
Does it work if you only use
http
instead?yes
if i hit that endpoint from the postman
i am able to hit it properly
i can debug
it is problem with the graph client
exact error:
HttpRequestException:An error occurred while sending the request. WebException:Unable to connect to the remote server SocketException:No connection could be made because the target machine actively refused it [::1]:44388
That's not the same port as the URL you posted?
That is trying to hit
44388
instead of 48843
lol
i just entered it
but it is configured value
it used the same value in the both places
anyone worked on graph api change notifications??
found the solutions
I lost my mind
the graph api makes the call to the localhost
we have to do a ngrok to access it