`sudo nix-channel –-update` reports ‘Couldn’t resolve host name’
Bug description
I am using Nixos WSL currently. It worked fine for a while before, but recently I suddenly found that network requests from nixos itself (such as downloading files when sudo nixos-rebuild switch, or sudo nix-channel update) cannot resolve the hostname.
$ sudo nix-channel --list
nixos https://nixos.org/channels/nixos-23.11
nixos-wsl https://github.com/nix-community/NixOS-WSL/archive/refs/heads/main.tar.gz
$ sudo nix-channel --update
warning: error: unable to download 'https://nixos.org/channels/nixos-23.11': Couldn't resolve host name (6); retrying in 259 ms
But I can download the corresponding files directly through wget without any problems. I want to know if there is any difference between downloading from nixos and downloading through wget that causes this to happen?
$ wget https://nixos.org/channels/nixos-23.11
--2024-06-29 06:12:48-- https://nixos.org/channels/nixos-23.11
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://channels.nixos.org/nixos-23.11 [following]
--2024-06-29 06:12:49-- https://channels.nixos.org/nixos-23.11
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 302 Moved Permanently
Location: https://releases.nixos.org/nixos/23.11/nixos-23.11.7714.90bd1b26e237 [following]
--2024-06-29 06:12:50-- https://releases.nixos.org/nixos/23.11/nixos-23.11.7714.90bd1b26e237
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 200 OK
Length: 4408 (4.3K) [text/html]
Saving to: ‘nixos-23.11’
nixos-23.11 100%[=================================================>] 4.30K --.-KB/s in 0s
2024-06-29 06:12:50 (27.8 MB/s) - ‘nixos-23.11’ saved [4408/4408]
I found this 'Couldn't resolve host name (6)' in nix-channel --update. But there is no such a file /run/systemd/resolve/stub-resolv.conf in Nixos-WSL. The file etc/resolv.conf is generated by wsl automatically. And I have tried setting generateResolvConf = false and use nameserver = 8.8.8.8. But it doesn't work
To Reproduce
sudo nix-channel --update
WSL version
WSL Version: 2.2.4.0
Kernel Version: 5.15.153.1-2
WSLg Version: 1.0.61
MSRDC Version: 1.2.5326
Direct3D Version: 1.611.1-81528511
DXCore Version: 10.0.26091.1-240325-1447.ge-release
Windows Version: 10.0.22631.3737
I've tried install a brand new Nixos-WSL from latest image. The same error occured on my very first command
$ sudo nix-channel --update
warning: error: unable to download 'https://nixos.org/channels/nixos-23.11': Couldn't resolve host name (6); retrying in 250 ms
warning: error: unable to download 'https://nixos.org/channels/nixos-23.11': Couldn't resolve host name (6); retrying in 649 ms
warning: error: unable to download 'https://nixos.org/channels/nixos-23.11': Couldn't resolve host name (6); retrying in 1408 ms
warning: error: unable to download 'https://nixos.org/channels/nixos-23.11': Couldn't resolve host name (6); retrying in 2017 ms
This issue might be the most relative nix no longer loads channel or cache
Connecting to 127.0.0.1:7890... connected.
Do you have some proxy configured?
Connecting to 127.0.0.1:7890... connected.Do you have some proxy configured?
I do have a proxy in Windows and no proxy in NixOS. And I am using mirroed network mode. But I don't think it makes sense that the same URL can be accessed in curl but not in sudo nix-channel update. I have also tried removing all proxies, and the same thing happens.
I have a similar issue when using nixos-rebuild switch --flake. Fetching from cache works fine, but seems like fetchers in derivations misbehave.
building '/nix/store/4ipi4f5qrd23ppdjwkjxvsqj2d4c36fn-index-x86_64-linux.drv'...
building '/nix/store/pk0yk0ij0ywlbmjy3a0pb4wipsg0pay9-crate-cc-1.0.105.tar.gz.drv'...
error: builder for '/nix/store/4ipi4f5qrd23ppdjwkjxvsqj2d4c36fn-index-x86_64-linux.drv' failed with exit code 1;
last 25 log lines:
> sourcing setup hook '/nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh'
> sourcing setup hook '/nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh'
> sourcing setup hook '/nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh'
> sourcing setup hook '/nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh'
> sourcing setup hook '/nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh'
> sourcing setup hook '/nix/store/jivxp510zxakaaic7qkrb7v1dd2rdbw9-multiple-outputs.sh'
> sourcing setup hook '/nix/store/ilaf1w22bxi6jsi45alhmvvdgy4ly3zs-patch-shebangs.sh'
> sourcing setup hook '/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh'
> sourcing setup hook '/nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh'
> sourcing setup hook '/nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh'
> sourcing setup hook '/nix/store/gps9qrh99j7g02840wv5x78ykmz30byp-strip.sh'
> error checking the existence of https://tarballs.nixos.org//sha256-vmskcljT3AyS+tmXcElPTIXSzm0YpqwNDF9Yw2Uqn+w=:
> curl: (6) Could not resolve host: tarballs.nixos.org
>
> trying https://github.com/nix-community/nix-index-database/releases/download/2024-07-07-025737/index-x86_64-linux
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: github.com
> Warning: Problem : timeout. Will retry in 1 seconds. 3 retries left.
> 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: github.com
> Warning: Problem : timeout. Will retry in 2 seconds. 2 retries left.
> 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: github.com
> Warning: Problem : timeout. Will retry in 4 seconds. 1 retries left.
> 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: github.com
> error: cannot download index-x86_64-linux from any mirror
For full logs, run 'nix log /nix/store/4ipi4f5qrd23ppdjwkjxvsqj2d4c36fn-index-x86_64-linux.drv'.
error: 1 dependencies of derivation '/nix/store/f7xrx64fcignb7b2kp1ha7acai6k616l-comma-with-db-1.8.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9akwli30jd5z0fhadh56yy0g4s4ry7q7-home-manager-files.drv' failed to build
error: 1 dependencies of derivation '/nix/store/y22k89jr7k81nfrxr8pa5isv7c6ffnwg-nix-index-with-db-0.1.8.drv' failed to build
error: 1 dependencies of derivation '/nix/store/7afr2qashcw7yxjlc3ssp8ckd8l80v6a-home-manager-generation.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ijad5yqd5fafgpcciqh98k6h2sas5hpj-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/60szmk5ki1vr99l2dv35arbhknp3sqnn-unit-home-manager-nixos.service.drv' failed to build
error: 1 dependencies of derivation '/nix/store/4vjag0skqk3cgxxws5m04qzz32677kxh-user-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/jnmf41nmidb4lhihy0i8pvb98zsprlva-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/5cj7hklfgfkzdv3jw77jmj1hmapfm4x9-nixos-system-nixos-24.11pre-git.drv' failed to build
@Chiichen did you manage to resolve your issue?
Changing nix version to just nix helped. Previously, I had nix.package = pkgs.nixVersions.nix_2_21.
Changing nix version to just
nixhelped. Previously, I hadnix.package = pkgs.nixVersions.nix_2_21.
I don't have such setting actually
@Chiichen did you manage to resolve your issue?
I tried many methods, but nothing worked.
have you used the correct syntax? @Chiichen
wsl.wslConf.network.generateResolvConf = false;
networking.nameservers = [ "1.1.1.1" "9.9.9.9" ];
您使用了正确的语法吗?@Chiichen
wsl.wslConf.network.generateResolvConf = false; networking.nameservers = [ "1.1.1.1" "9.9.9.9" ];
For sure, I have turned to install Nixos on a seperate disk and use it as a physical machine instead of running in WSL VM.
Sorry for openning this issue again, but I tried NixOS on WSL lately and still have this issue, Ubuntu on other hand im able to connect and update packages. Also im behind a proxy.
Trying curl -v on 'https://nixos.org/channels/nixos-24.05' give me the same error reported in:
- https://github.com/NixOS/nixpkgs/issues/337982
- https://github.com/curl/curl/issues/10702
Sorry for openning this issue again, but I tried NixOS on WSL lately and still have this issue, Ubuntu on other hand im able to connect and update packages. Also im behind a proxy.
Trying curl -v on 'https://nixos.org/channels/nixos-24.05' give me the same error reported in:
Are you getting an error message referencing certificates or hostname?