4

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?

Sriram Tamilarasan
  • 491
  • 1
  • 6
  • 23
  • 4
    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 02 '19 at 12:43
  • Please include relevant code. Is your bot throwing the error, or a client? – mdrichardson Jul 02 '19 at 17:27
  • 1
    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 '19 at 12:56
  • My simple query is endpoint url is working fine in local host but throws No such host error in Azure. – Sriram Tamilarasan Jul 10 '19 at 12:59
  • 1
    @SriramTamilarasan i am encountering the same problem how did you solve it? – user10860402 Aug 22 '19 at 00:38
  • 1
    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 '20 at 10:39
  • 1
    what was your solution and finding? – Emil Jan 12 '22 at 16:12

1 Answers1

6

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:

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

  2. 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.

  3. 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'

V. S.
  • 1,086
  • 14
  • 14