Centos - golang 1.6/1.7 - dial tcp i/o timeout

1,140 views
Skip to first unread message

subbagu...@gmail.com

unread,
Oct 16, 2016, 4:54:43 PM10/16/16
to golang-nuts

Getting dail tcp error while calling httpClient.Get or httpClient.Post


http client settings:
httpClient = &http.Client{
Timeout: 30 * time.Second,
}

Error:

dial tcp: lookup on xx.xx.xx.xxx:53: dial udp xx.xx.xx.xxx:53: i/o timeout


CentOS version: CentOS Linux release 7.2.1511 (Core) 


can you provide the resolution for this?

Ian Lance Taylor

unread,
Oct 16, 2016, 6:01:44 PM10/16/16
to subbagu...@gmail.com, golang-nuts
Looks like your DNS server is not responding to your Go program. Any
idea why? Firewall issue? Misunderstanding of DNS config files? You
could try setting `GODEBUG=netdns=cgo` in the environment; see
https://golang.org/pkg/net.

Ian

robert...@gmail.com

unread,
Oct 17, 2016, 12:24:12 PM10/17/16
to golang-nuts, subbagu...@gmail.com
Is there a way in Golang to cache the response from the DNS server? Java apps by default cache the DNS info until the app gets restarted.

Ian Lance Taylor

unread,
Oct 17, 2016, 12:36:13 PM10/17/16
to robert...@gmail.com, golang-nuts, subbagu...@gmail.com
On Mon, Oct 17, 2016 at 8:26 AM, <robert...@gmail.com> wrote:
> Is there a way in Golang to cache the response from the DNS server? Java
> apps by default cache the DNS info until the app gets restarted.

You can do DNS lookups yourself using `net.LookupHost` and friends.

Ian

> On Sunday, October 16, 2016 at 5:01:44 PM UTC-5, Ian Lance Taylor wrote:
>>
>> On Sun, Oct 16, 2016 at 9:10 AM, <subbagu...@gmail.com> wrote:
>> >
>> > Getting dail tcp error while calling httpClient.Get or httpClient.Post
>> >
>> >
>> > http client settings:
>> > httpClient = &http.Client{
>> > Timeout: 30 * time.Second,
>> > }
>> >
>> > Error:
>> >
>> > dial tcp: lookup on xx.xx.xx.xxx:53: dial udp xx.xx.xx.xxx:53: i/o
>> > timeout
>> >
>> >
>> > CentOS version: CentOS Linux release 7.2.1511 (Core)
>> >
>> >
>> > can you provide the resolution for this?
>>
>> Looks like your DNS server is not responding to your Go program. Any
>> idea why? Firewall issue? Misunderstanding of DNS config files? You
>> could try setting `GODEBUG=netdns=cgo` in the environment; see
>> https://golang.org/pkg/net.
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

subbagu...@gmail.com

unread,
Oct 19, 2016, 1:15:57 PM10/19/16
to golang-nuts, subbagu...@gmail.com

This issue was due to golang 1.7 version and it is resolved after build the code with golang 1.7.1 version.

For details:
Reply all
Reply to author
Forward
0 new messages