❔ Local Environment throwing exception when calling HttpClient.GetStringAsync

I am running the below code via Visual Studio Code, and a "The requested address is not valid in its context. (www.mypublicwebsite.com:443)" exception is thrown, an inner SocketException with error code 10049 is thrown too but I cannot figure out why it is called, I believe my local is setup to allow the program to connect to public internet sites. using (var httpClient = new HttpClient()) { await httpClient.GetStringAsync("https://www.mypublicwebsite.com"); }
10 Replies
Stan
Stan13mo ago
I'm guesing that's an example URL and the actual URL does load (in your browser for example)? the error code indicates that it can't find the IP behind the domain. If it's a fresh domain or recently changed IP records, it could be a dns propagation issue.
Deleted User 93w4ls0g
Yep it's an example URL, the actual URL does load. It's as if my local machine won't access / recognize external URLs
Stan
Stan13mo ago
hmm but your browser does? does it work with google.com or something else public? does it work with any http server you have running in your lan?
Deleted User 93w4ls0g
It doesn't work with google.com, I tried it with google and a load of other valid well-known sites and I'm getting the same error.
Stan
Stan13mo ago
but it works on your browser and its in the same machine? no docker or VM or anything funny like that/
Deleted User 93w4ls0g
Yep works on the browser and it's in the same machine. I'm not using docker or a VM just using the C# extension to compile C# in VS Code
Stan
Stan13mo ago
this is a smelly bug 😠 can you try it with an IP addres like https://1.1.1.1 dns vibecheck are you sure that its not another part of your code triggering the error? its either that or you have some weirdness in your network. or im completely lost
Deleted User 93w4ls0g
This message is what solved it! I had a problem with my network. I reset the router and I am now getting responses!
Stan
Stan13mo ago
ayyy nice! thanks for letting me know, it was nibbling at my brain
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server