@eludom I'm on NixOS. I just added `networking.extraHosts = ...` in my configuration.nix file. The string you assign that value to basically just gets added to your /etc/hosts file.
By pointing domains that I don't want to connect with to localhost, the service will immediately fail to connect, since I'm not hosting a web server on my machine.