Golang dial tcp: lookup no such host

Golang dial tcp: lookup no such host

Show

    于 2022-01-06 19:19:59 首次发布

    dial tcp: lookup xxx.com on 8.8.8.8:53: no such host

    最近在执行go mod tidy更新依赖库时遇到如下问题:

     dial tcp: lookup xxx.com on 8.8.8.8:53: no such host
    
    
    
     但我的mac明明没有任何地方配置8.8.8.8啊, 而且我抓包看了,mac确实没有给8.8.8.8发任何请求。
    
     继续仔细分析,看到这个提示:
    
     reading https://sum.golang.org/lookup/xxx.com
    
     就是这里了,原来是这里在向8.8.8.8发起请求,然后8.8.8.8无法识别。
    
    
    
     问题原因:Go 1.13设置了默认的GOSUMDB=sum.golang.org,它当然是无法识别私有域名xxx.com .
    
     解决办法:
    
     go env -w GOPRIVATE=xxx.como
    
     或者:
    
     go env -w GOSUMDB=off
    

    搞了好长时间没弄出来,看了一篇博客顺利解决问题,一看作者,竟然是涛哥。。。果然厉害。
    原文链接:https://blog.csdn.net/stpeace/article/details/106875395

    原创

    ghostwritten 2022-05-31 00:38:53 博主文章分类:kubernetes ©著作权

    文章标签 kubernetes 无法识别 golang 文章分类 kubernetes 云计算

    ©著作权归作者所有:来自51CTO博客作者ghostwritten的原创作品,请联系作者获取转载授权,否则将追究法律责任

    reading https://sum.golang.org/lookup/xxx.com

    就是这里了,原来是这里在向8.8.8.8发起请求,然后8.8.8.8无法识别。

    问题原因:Go 1.13设置了默认的GOSUMDB=sum.golang.org,它当然是无法识别私有域名xxx.com .
    解决办法:

    go env -w GOPRIVATE=xxx.como

    或者:

    go env -w GOSUMDB=off

    • 收藏
    • 评论
    • 举报

    上一篇:1. 认识kubernetes

    下一篇:Python 下载的 8种

    unread,

    Jul 30, 2013, 12:41:14 PM7/30/13

    to

    unread,

    Aug 16, 2013, 2:19:22 AM8/16/13

    to

    Updates:
    Labels: -Go1.2Maybe Go1.3Maybe

    Comment #19 on issue 3575 by : net: LookupHost("localhost")

    Not sure what to do. Deferring to Go1.3 so we can revisit it then and hope
    the underlying problem fixed.

    unread,

    Oct 14, 2013, 12:26:33 AM10/14/13

    to

    Comment #21 on issue 3575 by : net:

    Verified on OSX 10.8.4. The exhaustion seems to be FD related to kqueue.
    Both the go program and a simple python program. lsof indicates about 250
    open KQUEUE file handles.

    Attachments:
    dnserror.py 128 bytes

    unread,

    Dec 2, 2013, 3:23:11 PM12/2/13

    to

    Comment #24 on issue 3575 by : net: LookupHost("localhost")

    I can also confirm that I have this problem on multiple environments
    (latest OSX, CentOS 6, CentOS 5 and Ubuntu 13.10). All 64 bit machines.

    unread,

    Dec 9, 2013, 12:54:23 AM12/9/13

    to

    Comment #27 on issue 3575 by : net:

    My go code kicks off 16 goroutines to concurrently run sql on postgresql
    databases that are on hosts n01..n16 on my local network.

    Once in a while (but not always) I get errors such as these:
    dbh.Prepare():dial tcp: lookup n02: no such host
    dbh.Prepare():dial tcp: lookup n05: no such host
    Usually when this occurs only 2 to 3 hosts are not found, while the rest
    are found.

    When I do another run of the program immediately after getting such errors,
    then the errors dissappear.

    Also if I replace the hostnames by ip-addresses in the database connection
    parameter string, then the errors do not occur.

    System: debian linux running kernel 3.2.0-4-amd64
    Go version go1.2 linux/amd64

    unread,

    Dec 9, 2013, 2:47:38 AM12/9/13

    to

    unread,

    Aug 18, 2014, 10:43:05 AM8/18/14

    to

    Comment #29 on issue 3575 by : net: LookupHost("localhost")

    Still having this problem on Go 1.3.1.

    unread,

    Aug 18, 2014, 1:48:15 PM8/18/14

    to

    Comment #30 on issue 3575 by : net:

    fiorix, what version of glibc do you have? It's likely you don't have their
    fix yet. I think this was determined to not be a Go bug (see Issue 6336).
    We might detect and work around it, though.

    Alternatively, you can update your glibc, or use the netgo build tag and
    use Go's built-in DNS resolver instead of the system one.

    unread,

    Aug 27, 2014, 7:39:31 PM8/27/14

    to

    Comment #31 on issue 3575 by : net: LookupHost("localhost")

    returning "no such host" error

    https://code.google.com/p/go/issues/detail?id=3575

    It's Ubuntu 14.04 with the latest libc 2.19. I've been following Issue 6336
    as well. Tried the netgo build tag (go install -a -tags netgo std and netgo
    net iirc) but dns resolution eventually stops working after a while.
    Perhaps because my program uses sqlite thus cgo can't be disabled? Not sure
    if that has anything to do with it.

    unread,

    Sep 12, 2014, 10:18:37 AM9/12/14

    to

    Comment #32 on issue 3575 by : net: LookupHost("localhost")

    Works by doing "go install -a -tags netgo net my-pkg"

    unread,

    Nov 23, 2014, 11:22:45 PM11/23/14

    to

    Comment #33 on issue 3575 by : net:

    Sorry, I'm pretty new. How do I do a lock around net.cgoLookupIPCNAME?

    unread,

    Nov 24, 2014, 12:01:04 AM11/24/14

    to

    Comment #34 on issue 3575 by : net:

    Sorry for the double post but this one includes more details. How do I do a
    lock around net.cgoLookupIPCNAME?

    When I try the workaround as suggested in #32 I get:
    "go install runtime: open /usr/local/go/pkg/linux_amd64/runtime.a:
    permission denied".

    If I sudo then it seems to work but then when I try to install other
    packages I get:

    "go install container/list: open
    /usr/local/go/pkg/linux_amd64/container/list.a: permission denied
    go install unicode/utf8: open /usr/local/go/pkg/linux_amd64/unicode/utf8.a:
    permission denied
    go install crypto/subtle: open
    /usr/local/go/pkg/linux_amd64/crypto/subtle.a: permission denied
    go install hash: open /usr/local/go/pkg/linux_amd64/hash.a: permission
    denied
    go install unicode: open /usr/local/go/pkg/linux_amd64/unicode.a:
    permission denied".

    I then uninstalled then reinstalled Go. Am I doing something wrong here?
    Using Linux Mint 17.

    unread,

    Nov 24, 2014, 10:59:17 AM11/24/14

    to

    Comment #35 on issue 3575 by : net: LookupHost("localhost")

    The question about permission errors with "go install runtime" doesn't have
    anything to do with this issue. Please take that question to golang-nuts.
    (It should work as long as you are consistent about the user running "go
    install" but please do not reply here.)