Terraform complains: dial tcp: lookup │ registry.terraform.io: no such host

Hello there,

My laptop is behind company proxy, my Terraform version is 1.4.5 on Windows 10, it complains: dial tcp: lookup
registry.terraform.io: no such host when I ran: terraform init

> terraform init
Initializing modules...

Initializing provider plugins...
- Reusing previous version of hashicorp/vault from the dependency lock file

 Error: Failed to query available provider packages

 Could not retrieve the list of available versions for provider hashicorp/vault: 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: no such host

But I can get the file with wget:

> wget https://registry.terraform.io/.well-known/terraform.json        


StatusCode        : 200
StatusDescription : OK
Content           : {"modules.v1":"/v1/modules/","providers.v1":"/v1/providers/"}

RawContent        : HTTP/1.1 200 OK
                    Connection: keep-alive
                    Content-Security-Policy: default-src 'self'; script-src 'self'
                    'unsafe-inline' https://www.google-analytics.com https://cdn.segment.com  
                    https://unpkg.com/@segm...

Could anyone please shed some lights on this problem?

Thanks and Best Regards,

Arthur

Hi @art-niu!

What special configuration have you added to your system to help wget know it’s supposed to use the proxy?

Lots of different parts of Terraform access remote servers over the network, but this particular one is the provider installer that’s built in to Terraform CLI, and I would have expected it to respect the typical HTTPS_PROXY environment variable for configuring proxy servers. But I’m not sure if that’s what the problem is here, since these various middlebox products all seem to do their work a little differently and require different workarounds to get software working with them.

Thanks, @apparentlymart

In my env, I am using script proxy with Wifi, even after I overwrote the proxy settings, it is still same. Is there any proxy settings within Terraform can be tweaked?

PS C:\iac\iac-vault\lab> echo $env:HTTPS_PROXY
http://proxy.csd.ca:8888
PS C:\iac\iac-vault\lab> terraform init
Initializing modules...
Initializing the backend...

Initializing provider plugins...
- Reusing previous version of hashicorp/vault from the dependency lock file
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/vault: could not connect to
│ registry.terraform.io: Failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": Forbidden
╵

PS C:\iac\iac-vault\lab> wget https://registry.terraform.io/.well-known/terraform.json


StatusCode        : 200
StatusDescription : OK
Content           : {"modules.v1":"/v1/modules/","providers.v1":"/v1/providers/"}

RawContent        : HTTP/1.1 200 OK
                    Connection: keep-alive
                    Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'
                    https://www.google-analytics.com https://cdn.segment.com https://unpkg.com/@segm...

Thanks,

Arthur