Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
net: LookupHost returns "no such host" when dns request timeout #10417
What version of Go are you using (go version)?
go version go1.4.2 linux/amd64
What operating system and processor architecture are you using?
Ubuntu 14.04.1 LTS
What did you do?
In this case DNS resolver doesn't response to queries.
What did you expect to see?
What did you see instead?
lookup 1428707955.plus.google.com.: no such host
How to reproduce the problem?
The test conducted uses an iptables rule to drop all inbound DNS responses. And the host used for the test "X.plus.google.com" (X = a timestamp) has a wildcard DNS record, so it should exist regardless what "X" is.
Test code and log is available at:
$ sudo apt-get install ngrep $ git clone https://gist.github.com/b97db1606258385cc32d.git $ cd b97db1606258385cc32d $ chmod +x reproduce.sh $ ./reproduce.sh
Note that, this error is also reproducible on
By default, unless you did something unusual when you built the Go compiler, the Go DNS client simply calls the system function getaddrinfo in this case. That error means that getaddrinfo returned EAI_NONAME. That is usually displayed as "Name or service not known" but to make the different DNS implementations more compatible the Go library converts it to "no such host".
Unfortunately, as far as I can see, the getaddrinfo function has no way to indicate a timeout or a failure to contact the DNS servers. When using the native Go DNS client, it is possible to get a timeout error. When calling getaddrinfo, which is the default, that is not possible.
If you build your own Go distribution, you can force use of the native Go DNS client rather than getaddrinfo by building your program with "go build -tags netgo -installsuffix netgo". But I don't see any way to fix this with the default build.