dqmchw0071
dqmchw0071
2016-08-15 16:31

在Termux中运行Go应用时出现DNS查找问题

已采纳

I am trying to write a Go App that lets me spawn Digital Ocean droplets. It works fine on my desktop and laptop, but when I try to run it on my Android phone in Termux I get the issue shown in the image. I already filed an issue on their GitHub, but I am not sure if this is related to Termux or if I am missing something.

Here is part of the error:

dial tcp: lookup api.digitalocean.com on [::1]:53: read udp [::1]:39143->[::1]:53: read: connection refused

Not sure why it is trying to use localhost as a dns server. Here is an image:

Image in question

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dtpa98038 dtpa98038 3年前

    Just create /etc/resolv.conf and append nameserver 8.8.8.8 then this problem will be resolved.

    According to src/net/dnsclient_unix.go, if /etc/resolv.conf is absent, localhost:53 is chosen as a name server.

    Since the Linux in Android is not so "standard". /etc/resolv.conf is not available. The app then just keep looking up host in localhost:53.

    点赞 评论 复制链接分享
  • donglin9068 donglin9068 4年前

    Your phone is trying to connect to itself: [::1]:39143->[::1]:53

    My guess is your phone is probably not running a local DNS server and so you get the connection refused error.

    Your nslookup is irrelevant because you connected directly to 8.8.8.8. Instead, try nslookup ::1 or dig @::1 google.com A

    点赞 评论 复制链接分享