Home
%3CLINGO-SUB%20id%3D%22lingo-sub-334369%22%20slang%3D%22en-US%22%3E%E2%80%9CNo%20such%20host%20is%20known%E2%80%9D%20error%20in%20Visual%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-334369%22%20slang%3D%22en-US%22%3E%3CP%3EError%20messages%20like%20%E2%80%9CSocket%20Exception%3A%20No%20such%20host%20is%20known%E2%80%9D%20refers%20to%20issues%20in%20the%20code%20or%20configuration%20of%20your%20application.%20Here%20is%20an%20example%20error%20message%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3ESystem.Net.Sockets.SocketException%3A%20No%20such%20host%20is%20known%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F72636i8329D19421061E5C%2Fimage-dimensions%2F400x287%3Fv%3D1.0%22%20width%3D%22400%22%20height%3D%22287%22%20alt%3D%22cc1.jpg%22%20title%3D%22cc1.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1676103106%22%20id%3D%22toc-hId-1733362366%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--876053855%22%20id%3D%22toc-hId--818794595%22%3ERoot%20cause%3C%2FH2%3E%0A%3CP%3EIn%20my%20case%2C%20the%20root%20cause%20was%20a%20failure%20in%20DNS%20name%20resolution.%20The%20application%20was%20trying%20to%20call%20an%20API%20but%20it%20is%20not%20able%20to%20find%20the%20hostname.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-866756480%22%20id%3D%22toc-hId-924015740%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--1685400481%22%20id%3D%22toc-hId--1628141221%22%3ESolution%3C%2FH2%3E%0A%3CP%3EYour%20server%20should%20be%20able%20to%20access%20to%20the%20DNS%20server.%20Additionally%2C%20your%20DNS%20server%20should%20be%20able%20to%20lookup%20the%20hostname%20that%20is%20in%20your%20code.%20Troubleshooting%20steps%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ERun%3CCODE%3Eipconfig%20%2Fall%3C%2FCODE%3E%20in%20Command%20Prompt.%20Fin%20the%20IP%20addresses%20of%20the%20DNS%20server%20in%20the%20output.%20Try%20to%20ping%20it.%3C%2FLI%3E%0A%3CLI%3ERun%20%3CCODE%3Enslookup%3C%2FCODE%3E.%20Enter%20the%20hostname%20from%20your%20code.%20The%20DNS%20server%20should%20be%20able%20to%20reach%20this%20hostname.%3C%2FLI%3E%0A%3CLI%3EMake%20sure%20there%20is%20no%20typo%20or%20white%20spaces%20in%20the%20hostname.%20In%20case%20you%20are%20getting%20this%20input%20from%20a%20JSON%20call%20or%20configuration%20file%2C%20the%20source%20string%20and%20the%20variable%20might%20have%20different%20values.%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-334369%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EError%20messages%20like%20%E2%80%9CSocket%20Exception%3A%20No%20such%20host%20is%20known%E2%80%9D%20refers%20to%20issues%20in%20the%20code%20or%20configuration%20of%20your%20application.%20%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

Error messages like “Socket Exception: No such host is known” refers to issues in the code or configuration of your application. Here is an example error message:

 

System.Net.Sockets.SocketException: No such host is known

cc1.jpg

 

Root cause

In my case, the root cause was a failure in DNS name resolution. The application was trying to call an API but it is not able to find the hostname.

 

Solution

Your server should be able to access to the DNS server. Additionally, your DNS server should be able to lookup the hostname that is in your code. Troubleshooting steps:

  • Run ipconfig /all in Command Prompt. Fin the IP addresses of the DNS server in the output. Try to ping it.
  • Run nslookup. Enter the hostname from your code. The DNS server should be able to reach this hostname.
  • Make sure there is no typo or white spaces in the hostname. In case you are getting this input from a JSON call or configuration file, the source string and the variable might have different values.