Hi. Any idea how this issue can be resolved? ``` i...
# help
Hi. Any idea how this issue can be resolved?
Copy code
infracost auth login
We're redirecting you to our log in page, please complete that,
and return here to continue using Infracost.
Error: listen tcp: lookup localhost on [::1]:53: read udp [::1]:53353->[::1]:53: read: connection refused
@refined-motherboard-83704 one workaround is to go to dashboard.infracost.io > login > Org Settings and copy your API key then run
infracost configure set api_key MY_API_KEY
- let us know if that works for you
If you are running this command on a remote machine, it won’t work. These are instructions for a local machine. Please use Ali’s suggestion ☝️
Thank you!
I got a bit further now, but not quite there till the end
Copy code
infracost breakdown --path .                                                                                                                                     
Evaluating Terraform directory at .                                                                                                                                                                                 
  ✔ Downloading Terraform modules                    
  ✔ Evaluating Terraform directory                                                                                                                                                                                  
  ✖ Retrieving cloud prices to calculate costs                                                                                                                                                                      
Project: cardin1/terraform-book/1-intro-aws                                                                                                                                                                         
  Error sending API request:                                                                                                                                                                                        
    Post "<https://pricing.api.infracost.io/graphql>":                                                                                                                                                                
      POST <https://pricing.api.infracost.io/graphql> giving up after 5 attempt(s):                                                                                                                                   
        Post "<https://pricing.api.infracost.io/graphql>":                                                                                                                                                            
          dial tcp:                                                                                                                                                                                                 
            lookup <http://pricing.api.infracost.io|pricing.api.infracost.io> on [::1]:53:                                                                                                                                                            
              read udp [::1]:48266->[::1]:53:                                                                                                                                                                       
                  connection refused                                                                                                                                                                                

 OVERALL TOTAL       $0.00                           
No cloud resources were detected                     

┃ Project                                            ┃ Monthly cost ┃                                     
┃ cardin1/terraform-book/1-intro-aws                 ┃ $0.00        ┃                                     
This section might help https://www.infracost.io/docs/cloud_pricing_api/self_hosted/#cli-fails-to-connect-to-your-cloud-pricing-api. Specifically try this
curl -i <http://pricing.api.infracost.io/health|pricing.api.infracost.io/health>
to see if there is access to the outside world.
@refined-motherboard-83704 it would help if you can share context (e.g. are you behind a corporate proxy? are running the self-hosted cloud pricing api?) or reproduction steps - that’ll enable the community to help better
Thank you @busy-agent-35515
Copy code
curl -i <http://pricing.api.infracost.io/health|pricing.api.infracost.io/health>
HTTP/1.1 301 Moved Permanently
Server: awselb/2.0
Date: Tue, 24 Oct 2023 08:57:42 GMT
Content-Type: text/html
Content-Length: 134
Connection: keep-alive
Location: <https://pricing.api.infracost.io:443/health>

<head><title>301 Moved Permanently</title></head>
<center><h1>301 Moved Permanently</h1></center>
Thanks @white-airport-8778 I am running Arch Linux and installed
infracost-bin 0.10.29-1
from the AUR. I am not behind a corporate proxy and not hosting the api myself.
curl -i <https://pricing.api.infracost.io/health>
Thank you Vadim. Sorry, I thought I posted the result here but I forgot to send it.
Copy code
curl -i <https://pricing.api.infracost.io/health>
HTTP/2 200 
date: Wed, 25 Oct 2023 01:52:34 GMT
content-type: application/json; charset=utf-8
content-length: 20
x-powered-by: Express
access-control-allow-origin: *
etag: W/"14-Y53wuE/mmbSikKcT/WualL1N65U"

It looks like a problem with go:
Copy code
> go install <http://github.com/andremueller/md-publisher@latest|github.com/andremueller/md-publisher@latest>
go: <http://github.com/andremueller/md-publisher@latest|github.com/andremueller/md-publisher@latest>: module <http://github.com/andremueller/md-publisher|github.com/andremueller/md-publisher>: Get "<https://proxy.golang.org/github.com/andremueller/md-publisher/@v/list>": dial tcp: lookup <http://proxy.golang.org|proxy.golang.org> on [::1]:53: read udp [::1]:43766->[::1]:53: read: connection refused
Curl has no problems here either:
Copy code
> curl -i <https://proxy.golang.org/github.com/andremueller/md-publisher/@v/list>
HTTP/2 200 
accept-ranges: bytes
access-control-allow-origin: *
cache-control: public, max-age=60
content-length: 14
content-type: text/plain; charset=UTF-8
date: Wed, 25 Oct 2023 05:03:55 GMT
expires: Wed, 25 Oct 2023 05:04:55 GMT
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 0
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

Terraform has a problem too. The common denominator is Go.
Copy code
> terraform plan

Planning failed. Terraform encountered an error while generating this plan.

│ Error: retrieving AWS account details: validating provider credentials: retrieving caller identity from STS: operation error STS: GetCallerIdentity, exceeded maximum number of attempts, 9, 
https response error StatusCode: 0, RequestID: , request send failed, Post "<https://sts.ap-northeast-1.amazonaws.com/>": dial tcp: lookup <http://sts.ap-northeast-1.amazonaws.com|sts.ap-northeast-1.amazonaws.com> on [::1]:53: read udp
 [::1]:47449->[::1]:53: read: connection refused                                               
│   with provider["<http://registry.terraform.io/hashicorp/aws|registry.terraform.io/hashicorp/aws>"],
│   on <http://main.tf|main.tf> line 1, in provider "aws":
│    1: provider "aws" {
Outside the go ecosystem all networking connections work. What could be the reason?
hmm sorry I’m not sure
I turns out that the issue was name resolution
I am using systemd-resolved Software that relies on glibc's getaddrinfo(3) (or similar) will work out of the box, since, by default,
is configured to use nss-resolve(8) if it is available. To provide domain name resolution for software that reads
directly, such as web browsers and GnuPG, requires some work. Go must be part of this group.
Copy code
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
Fixed connection issues for all go applications. See https://wiki.archlinux.org/title/Systemd-resolved#DNS
Thanks for your help
super cool! thanks for sharing the fix 🙂