Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am developing bot solution, in which I am making REST call to get some details from other server.

In local host my code is working fine, but after publishing the code in Azure I am getting the below error:

System.Net.WebException: No such host is known No such host is known —> System.Net.Http.HttpRequestException: No such host is known —> System.Net.Sockets.SocketException: No such host is known

I am using HttpWebRequest option.

May I know what could be the reason?

from the origin server (the one making the request) can you dig the domain name to verify it resolves correctly? can you, likewise, dig the domain name from your location? usually "No such host" indicates a DNS resolution problem Jason FB Jul 2, 2019 at 12:43 I have given my question clearly. If you dont know the answer please leave it. Please dont make it as unclear. I have resolved this issue by myself. Sriram Tamilarasan Jul 10, 2019 at 12:56 I have noted that asp-waf.com returns this error message if the hosting website is dis-allowing bots and will return an error that rejects the port and connection. triggering a request from Azure on an end-user endpoint will trigger a block as end-users do not brows from a server in a data center. update the question and add the url as well as as error stack details so you may get a more definite answer Walter Verhoeven Apr 27, 2020 at 10:39

I'm not sure the solution below will work for you but it looks like the solution is worth to be checked out. Here is an answer that may have useful information. Take a look at this answer and check your solution accordingly:

The problem description:

I deployed a .NET Windows Service on Azure Virtual Machine running Windows Server with an opened port that allow me to connect to it, this service is like a server using socket. The problem is that when I try to connect from my PC to that hosted server it doesn't work and I get this exception: System.Net.Sockets.SocketException: 'No such host is known'. The port is opened and visible from my PC. Can someone tell me why I get that exception? If I run locally all works ok.

The answer:

The Exception seems to be a DNS issue. I am not familiar with C#, from networking, you could check the followings on your side:

  • Windows service is running and the port is listening on the Azure VM.

  • The port is allowed for outbound traffic from your PC and Inbound traffic on your Azure VM. Check the VM firewall settings on both sides between your PC and Azure VM. Also, you could check the NSG settings follow this. You could use telnet vmpublicIP port on your PC CMD to verify network connectivity.

  • Verify your PC can resolve the address of the hosted server if you connect it via its DNS name. You could use the NSlookup or DIG to verify this. If it's DNS issue, you also could add a line in hosts file (located in %WINDIR%\system32\drivers\etc on windows) mapping the hosted server's IP to a name. Hope this helps.

  • .NET Service System.Net.Sockets.SocketException: 'No such host is known'

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .