"Connection refused" with both B2 and S3

Had restic working fine on Arch Linux with a repository in B2 for a year or so without issue. Sometime last year (perhaps after an update to restic?), it began giving a “connection refused error” that I am at a loss of how to debug:

$ restic -r b2:my-bucket:my-key/ backup /home/my-user/repos/ 2>&1
Fatal: unable to open repository at b2:my-bucket:my-key/: dial tcp: lookup [api.backblazeb2.com](http://api.backblazeb2.com/) on [::1]:53: read udp [::1]:34947->[::1]:53: read: connection refused

$ restic -r b2:my-bucket:my-key list snapshots
Fatal: unable to open repository at b2:my-bucket:my-key: dial tcp: lookup api.backblazeb2.com on [::1]:53: read udp [::1]:51894->[::1]:53: read: connection refused

Current version I am using:

$ restic version

restic 0.15.1 compiled with go1.20 on linux/amd64

The only configuration I have are environment variables: I have set

B2_ACCOUNT_ID
B2_ACCOUNT_KEY
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
RESTIC_PASSWORD

What I have Tried

I ensured that the B2 endpoint is reachable from my machine, by running b2 authorize-account and b2 list-buckets on the same machine and confirming that they work just fine.

I note that the restic docs recommend using the S3 API to access B2. So I tried through S3 (after setting up the appropriate environment variables) and got a similar error:

$ restic -r s3:s3.us-west-001.backblazeb2.com/my-bucket/my-key list snapshots

Fatal: unable to open config file: Stat: Get "https://s3.us-west-001.backblazeb2.com/my-bucket/my-key/?location=": dial tcp: lookup s3.us-west-001.backblazeb2.com on [::1]:53: read udp [::1]:48826->[::1]:53: read: connection refused

Is there a repository at the following location?

s3:s3.us-west-001.backblazeb2.com/my-bucket/my-key

Finally, I confirmed that from a different machine (a MacBook) on the same network, restic works just fine with both the B2 and S3 APIs:

$ restic -r b2:my-bucket:my-key list snapshots

repository 09ab4cca opened successfully, password is correct
008da198994d1f47b38db9e52504201cc6a82706b674dbd53ae4816e36852dd4
009dc2757add1c5a4937af9d18d67c6a210266708a62da0e42c59a6d41433c24
...
...
$ restic -r s3:s3.us-west-001.backblazeb2.com/my-bucket/my-key list snapshots

repository 09ab4cca opened successfully, password is correct

created new cache in /Users/my-user/Library/Caches/restic

008da198994d1f47b38db9e52504201cc6a82706b674dbd53ae4816e36852dd4
009dc2757add1c5a4937af9d18d67c6a210266708a62da0e42c59a6d41433c24
...
...
...

One notable difference is that the MacBook has an older version of restic:

$ restic version

restic 0.11.0 compiled with go1.15.6 on darwin/amd64

Hi, and welcome to the forum!

I don’t have much time right now, but saw something which may help you in debugging: what I can see from the error message is that restic tries to resolve the hostname api.backblaze2b.com via IPv6 at localhost (::1) and the request got refused. This is the underlying problem.

Does something (like the systemd-resolvd stub resolver) run on ::1? Maybe check with netstat -ln? Run wireshark on lo and look at the DNS traffic?

Good luck! :slight_smile:

1 Like

Thanks for that insight!

That helped focus my googling, and it seems that this is a common issue that affects DNS resolution in Go-based apps (such as docker).

I don’t know what causes the problem, but adding

nameserver 8.8.8.8
nameserver 8.8.4.4

to my /etc/resolv.conf got it working for me (as it seems to for most people who encounter the same error in other contexts).

1 Like

Oh the joy of DNS issues :wink:

At least it’s in the error message (if you know what to look for) :stuck_out_tongue: