From b2bae905844d7a4706d5c3396345b5b294e6230b Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 2 Nov 2022 11:56:53 +0100 Subject: [PATCH] bitcoind: fix rare startup error Previously, dhcpcd and bitcoind starting up in parallel could lead to the following error in bitcoind: ``` bitcoind: libevent: getaddrinfo: address family for nodename not supported bitcoind: Binding RPC on address 127.0.0.1 port 8332 failed. bitcoind: Unable to bind any endpoint for ``` After the initial failure, the bitcoind service would always restart successfully. This race condition, where both applications were simultaneously manipulating network resources, was only triggered under specific hardware conditions. Fix it by running bitcoind after dhcp has started (by running after `network-online.target`). This bug and the fix only affect the default NixOS scripted networking backend. --- modules/bitcoind.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bitcoind.nix b/modules/bitcoind.nix index 23cb6d6..aca7603 100644 --- a/modules/bitcoind.nix +++ b/modules/bitcoind.nix @@ -381,7 +381,7 @@ in { # TODO-EXTERNAL: Instead of `wants`, use a future systemd dependency type # that propagates initial start failures but no restarts wants = [ "nix-bitcoin-secrets.target" ]; - after = [ "network.target" "nix-bitcoin-secrets.target" ]; + after = [ "network-online.target" "nix-bitcoin-secrets.target" ]; wantedBy = [ "multi-user.target" ]; preStart = let