Curl out of memory when querying nix binary cache

After upgrading to Nix 2.9.1 I’m getting a lot of curl out of memory errors.

My local (system) nix is now 2.9.1, however if I run something with Nix 2.8.1 (project’s nix version) it yields a lot of errors:

error: unable to download 'https://cache.nixos.org/nar/0b0dp6i8cw0ar9mx1fp9kj39q1hjlc1s2srrm63bcwxvi21xm39s.nar.xz': Out of memory (27)
AWS error '' (curlCode: 27, Out of memory), will retry in 0 ms
AWS error '' (curlCode: 27, Out of memory), will retry in 50 ms
AWS error '' (curlCode: 27, Out of memory), will retry in 100 ms

Running the diagnostics script: http://ix.io/40gY (btw could not even run this with nix-shell since more failures like above occurred)

My nix config has this cache defined (along with a private one, but this is the one throwing errors):

substituters = https://cache.nixos.org/ 
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= 

Have tried with VPN enabled and disabled with same outcome. Checking the diagnostics outcome there seems to be a lot of errors when attempting to reach cache.nixos.org which makes me wonder is this public cache still valid?

After I upgraded to nix 2.9.0, this error was happening all the time (upgrading to 2.9.1 resolved most of them). Is there a breaking change or incompatibility between 2.8 and 2.9 that are causing this issue?

minor update on this, I never found the cause but this seemed to happen when we provided a specific version of nix in the dev shell of our project which was different to the installed version of nix. Unsure whether this is even supported but certainly was causing this issue