hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.7k stars 9.55k forks source link

terraform init could not resolve domain #35904

Open KONE-XAD opened 1 week ago

KONE-XAD commented 1 week ago

Terraform Version

~/.../terraform/tf-k8s-cluster-hk $ terraform version
Terraform v1.9.5
on linux_arm64

Terraform Configuration Files

...terraform config...

Debug Output

│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/template: could not connect to registry.terraform.io: failed to request discovery
│ document: Get "https://registry.terraform.io/.well-known/terraform.json": dial tcp: lookup registry.terraform.io on [::1]:53: read udp
│ [::1]:55059->[::1]:53: read: connection refused
╵
~/.../terraform/tf-k8s-cluster-hk $
~/.../terraform/tf-k8s-cluster-hk $ ping registry.terraform.io
PING registry.terraform.io (198.18.0.9) 56(84) bytes of data.
64 bytes from 198.18.0.9: icmp_seq=1 ttl=64 time=0.559 ms
64 bytes from 198.18.0.9: icmp_seq=2 ttl=64 time=1.14 ms
^C
--- registry.terraform.io ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 0.559/0.853/1.147/0.294 ms
~/.../terraform/tf-k8s-cluster-hk $ curl "https://registry.terraform.io/.well-known/terraform.json"
{"modules.v1":"/v1/modules/","providers.v1":"/v1/providers/"}

Expected Behavior

download providers

Actual Behavior

could not resolve the domain, but ping is ok

Steps to Reproduce

$ terraform init

Additional Context

I use my android pad to exec "terraform init", and got worng

References

no

jbardin commented 1 week ago

Hi @KONE-XAD,

The error message looks like a misconfiguration of the host DNS, Terraform is being given a nameserver address of [::1]:53 but there is no server running there. The ping and curl binaries are probably linked against the host libc, which will use its internal name resolver.

Can you show how your host DNS is configured? If it's not possible to change the DNS settings, you may need to build Terraform with CGO_ENABLED specifically for android, since that uses a different libc implementation than most standard linux installations.