`zig fetch` unable to connect to server

I just was trying to build some random zig project with dependencies defined in build.zig.zon. And get this error:

error: unable to connect to server: TemporaryNameServerFailure

I tried using zig fetch directly, but as expected it gave the same error.

zig fetch https://pkg.machengine.org/mach-opus/32712fd091636037959720ee00036a060816a4f0.tar.gz

Any other software works absolutely fine: wget, curl, google-chrome… etc.

The TLS implementation wasn’t very good in 0.13. have you tried on master?

Hello. I run into the same issue on zig 0.15.
Is there a way to tell build.zig{,.zon} to use an external downloader (such as curl)?

1 Like

You could use add http/socks5 proxy support for package manager · Issue #15048 · ziglang/zig · GitHub as a workaround right now.

3 Likes

Hello @gyozo
Welcome to ziggit :slight_smile:

Are you using linux?
If yes, which server is listed in your /etc/resolv.conf?

Both Windows and posix platforms that link to their C library return TemporaryNameServerFailure when there is a temporary failure in DNS; a retry normally solves the problem.
When zig is running on linux without linking to the C library, it uses /etc/resolv.conf to find out the DNS server and after retrieving back data from the DNS server it might return TemporaryNameServerFailure.

Check this thread:

Specifically my comment here: error: TemporaryNameServerFailure when using package management on Termux · Issue #14636 · ziglang/zig · GitHub

In my case it only happened on Linux, and came down to some weird incompatibility between Ubuntu and my router’s DNS server feature (I think).

After changing the Linux DNS server from my router to Google’s (8.8.8.8 and 8.8.4.4) it started working.

The symptoms in other networking tools (like git) was that there was a 10 second pause (probably some sort of timeout) before a network operation would take place - but only for specific domains.

1 Like

If you don’t want to bother with zigfetch, try changing your DNS to cloudflare’s or google’s.