Visual Studio provides all-in-one experience for software developers. From coding to testing, it makes IT professional’s lives easier. Error messages like “Socket Exception: No such host is known” refers to certain issues in the code or configuration of the application. In this post, I will explain the root cause and solution for this error message.
This error message may appear in may forms. Here is one of them:
System.Net.Sockets.SocketException: No such host is known
In some cases, you may see the exception code 0x80004005 along with the error message above. In addition, if you are receiving ThreadAbortException, check this post out.
The root cause of the “No such host is known” error
In the scenario I tested and in the online posts I reviewed, the root cause was the same: DNS name resolution failure. Basically, your application tries to call an API URL or to connect to a service but it is not able to find the hostname or your server is not able to do DNS lookup for that hostname.
Since it is an issue with DNS name resolution, nothing you do with Visual Studio, IIS, TFS or Windows will help fixing this issue. However, a simple code update may do the magic!
Similar issues on external sites: CodeProject, GitHub, Microsoft Support.
Another Visual Studio error: Remote Debugging Monitor (MSVSMON.EXE)
Solution for “No such host is known” error
The solution is fairly simple. Make sure your server is able to access to the DNS server and your DNS server is able to lookup the hostname in your code. Follow the steps below to troubleshoot and solve this issue.
- In Command Prompt, run
ipconfig /all. This will list the IP addresses of the DNS server you use. Try to ping them. Additionally, check with a colleague to see he or she has the same configuration
nslookup. Enter the hostname in your code. Make sure the DNS server is able to lookup this hostname.
- Make sure there is no typo or white spaces in the hostname. If you are getting this input from a JSON call or configuration file, it is possible that the source string and the variable you have are different.
If this is an ASP.NET WebForms application, you may also come across Validation of viewstate MAC failed error. Follow the link for the specific solution for it.