Connection Issues with Zig build

I was trying to install the Zig language server (ZLS) by building it from source. I clone the project and run zig build inside. It hanged for a very long time and ultimately spitted out error: ConnectionTimedOut.

Need help!

Works for me. If you look at the build.zig.zon of zls, there are a couple of dependencies pointing to github (and even ! :astonished:). Can you try to check if you have access to those urls?

It seems I can. With wget I successfully download the file.

Also, sorry that I forgot to mention I am using proxy.

1 Like

Hey, folks, I am facing the same problem. My local environment can’t stably connect to Github. I setup an HTTP proxy for help, but seems zig build command does not honor http_proxy and https_proxy environment variable.

Have you happen to find a solution?


Same issue - sitting behind a proxy with being (completely) blocked;
I either get error: ConnectionRefused (on Windows during Fetch packages [1/2]) or
error: EndOfStream (in WSL2) when trying to build zls from master …
a solution for this would be a nice New Year surprise or late Xmas present :slight_smile:

Checkout this add http/socks5 proxy support for package manager · Issue #15048 · ziglang/zig · GitHub

For anyone still wondering, just fly to country without censorship (jk).

According to add http/socks5 proxy support for package manager · Issue #15048 · ziglang/zig · GitHub

You can download the package manually (and set the hash and stuff), or
Host the package in your localhost (or in some website accessible in your country) and configure build.zig.zon to use that url.

Well… it will be super expensive to fly to another country just to build the code. :slight_smile:

I have a second workaround which works fine for me: Instead of download remote package, use .dependencies.<package_name>.path property. It allows referencing a library in a relative path under build root. Thus, just use the steps:

  1. Use git submodule your dependencies to a submodule of your source folder. For example, you have a myproject referencing to a dependency project called mydep. Then use git submodule add
  2. Edit build.zig.zon with a code like below. If you can access Github via proxy. it should work like a charm.
    .name = "myproject",
    .version = "0.1.0",
    .dependencies = .{
        .mydep = . {
            .path = "mydep",
    .paths = .{

Btw, I’ve been using the manual download workaround since August 2023. Honestly it’s not always working. The problem is I can’t compute a hash myself. In regular case we rely on zig build to tell a hash mismatch on first build. However, the workaround requires the first downloading done by ourselves. Thus, it works only when we have existing project (which has .url and .hash commited to build.zig.zon already). When we have a new project which references to new paths, the workaround can’t work anyway.

I’m trying to hack Zig code myself but somehow I see more problems on proxy logic in std lib. It always complains an “EndOfStream” error. Not sure if it points to more problems in latest Zig 0.12.0. Still digging.

Reference of my post back to last August: A workaround to build Zig projects without direct network connection - Fuzhou Chen's Space

For anyone who want an example, please check my project as an example: GitHub - fuzhouch/consumezamgba: Example of consuming [zamgba]( .

This project refers to the main project I’m working on: GitHub - fuzhouch/zamgba. As I can’t access Github stably myself, I use git submodule to keep dependency under deps/zamgba folder. The folder path is defined in consumezamgba/build.zig.

So far it works pretty well for me.

Btw, this is also a good approach to consume an early project (like my zamgba) that do not have an offiical release.

1 Like