Termux-app: DNS issues with terraform

Created on 11 Oct 2018  路  5Comments  路  Source: termux/termux-app

I am trying to use terraform within termux to provision AWS infrastructure. I have a basic tf file that just tries to use the aws provisioner. When I run terraform init on my mac or ubuntu hosts, it downloads the plugin without issue. When I try on termux, I get the following error:

Error installing provider "aws": Get https://releases.hashicorp.com/terraform-provider-aws/: dial tcp: lookup releases.hashicorp.com on [::1]:53: read udp [::1]:37606->[::1]:53: read: connection refused

I have read that there are possible issues with the go dns resolver that may cause this, but I'm unsure of how to correct it. I am able to perform a nslookup on the domain above and get the proper DNS entries returned.

210 looks to be a similar issue, but they were running go code and terraform is a precompiled binary for linux 64bit. I am running this on a chromebook with an intel processor. dpkg --print-architecture shows i686. I was able to install golang and run the sample code from #210 and that worked fine.

Most helpful comment

@jbrockett Just a difference in typical linux dns resolver and android's.

Problem comes from here (found via strace):

26998 openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC <unfinished ...>

- Linux uses /etc/resolv.conf to get DNS servers while Android doesn't use/have this file.

This can be fixed only with proot, but will require a binary compiled for the same architecture as your termux installation:

  1. Install necessary packages:
pkg install proot resolv-conf
  1. Bind resolv.conf file to right place when executing binary:
proot -b $PREFIX/etc/resolv.conf:/etc/resolv.conf {YOUR_BINARY}

Alternatively, you can use termux-chroot and you won't have to type proot -b .......

All 5 comments

I'm having the exact same issue. Any progress?

I ended up having to run ubuntu under proot in order to use terraform. I tried alpine, but ran into other issues getting it to run there. I've read other people have been able to run terraform successfully under termux, so I hope it's something easily fixed and I can go back to stock termux.

@jbrockett Just a difference in typical linux dns resolver and android's.

Problem comes from here (found via strace):

26998 openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC <unfinished ...>

- Linux uses /etc/resolv.conf to get DNS servers while Android doesn't use/have this file.

This can be fixed only with proot, but will require a binary compiled for the same architecture as your termux installation:

  1. Install necessary packages:
pkg install proot resolv-conf
  1. Bind resolv.conf file to right place when executing binary:
proot -b $PREFIX/etc/resolv.conf:/etc/resolv.conf {YOUR_BINARY}

Alternatively, you can use termux-chroot and you won't have to type proot -b .......

so I hope it's something easily fixed and I can go back to stock termux.

Easy fix is to recompile terraform for Termux with GOOS=android.

I had tried to get this to work previously with termux-chroot, but was missing the resolv-conf package. After installing that, terraform works from termux without recompiling. Thanks for the tip!

Was this page helpful?
0 / 5 - 0 ratings