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.
Asked
Active
Viewed 1.8k times
1

Eduard Stefanescu
- 411
- 2
- 9
- 19
-
1When you say you opened a port, can you detail what you mean? Did you in fact open the port under the network settings of the VM in the Azure Portal, as well as in the firewall on the VM? – Brendan Green Dec 31 '18 at 00:24
-
1`connect from my PC to that hosted server it doesn't work and I get this exception` does your pc can resolve to the address of the server? did you connect using a domain name or an ip address? – Bagus Tesa Dec 31 '18 at 01:28
1 Answers
2
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 hosted server if you connect it via its DNS name. You could use the
NSlookup
orDIG
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.

Nancy
- 26,865
- 3
- 18
- 34
-
Thank you! This is somehow the solution. I didn't configure the DNS Server on VM, that was the problem. Now it's working. – Eduard Stefanescu Dec 31 '18 at 10:16