Can't access some websites, sometimes

I’ve just installed NixOS and everything was working great until I opened opened Firefox and tried to log in.

I got the message

Hmm. We’re having trouble finding that site.

We can’t connect to the server at ...

I ignored it at the time and continued using the browser, but it has been happening sometimes for some websites. The weird thing is, some of those websites, when I try multiple times, end up working but then end up with the error again. I’ve never had this happen and it’s really annoying. I’ve tried disabling ipv6, using a custom DNS and disabling the firewall, but no results.

Just a reminder that this only happens in a few sites (most work), and it’s not an issue with my network.

1 Like

Does this occur with all browsers?

Yes and also with curl. I don’t think the browser itself has anything to do with the problem.

Anything strange in the journal?

I haven’t found anything out of the ordinary

Did a different OS on the same machine never have this issue?

Right. I’ve had Arch, Endeavour, Fedora as well as Windows (11 and 10) and never had this issue. Also, thanks for helping out :slight_smile:

Long shot. Do you have redistributable firmware enabled?

I do not. I tried putting it on and off but the issue persists.

If this helps, here are my Nix files:

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-amd" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/2ee4a3fb-5973-4b0f-9ad4-189acef3c277";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/8679-4029";
      fsType = "vfat";
      options = [ "fmask=0022" "dmask=0022" ];
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp4s0.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp7s0.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  fileSystems."/home/kraktoos/hdd" = {
    device = "/dev/disk/by-uuid/EA64AE7864AE4763";
    fsType = "ntfs";
    options = [ "rw" "uid=1000" "gid=100" "umask=0022" "nofail" ];
  };

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/Lisbon";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "pt_PT.UTF-8";
    LC_IDENTIFICATION = "pt_PT.UTF-8";
    LC_MEASUREMENT = "pt_PT.UTF-8";
    LC_MONETARY = "pt_PT.UTF-8";
    LC_NAME = "pt_PT.UTF-8";
    LC_NUMERIC = "pt_PT.UTF-8";
    LC_PAPER = "pt_PT.UTF-8";
    LC_TELEPHONE = "pt_PT.UTF-8";
    LC_TIME = "pt_PT.UTF-8";
  };

  # Configure keymap in X11
  services.xserver = {
    layout = "us";
    xkbVariant = "";

    enable = true;

    desktopManager = {
      xterm.enable = false;
    };

    displayManager = {
      defaultSession = "none+i3";
    };

    windowManager.i3 = {
      enable = true;
      extraPackages = with pkgs; [
        rofi
	autotiling
	gummy
	xcompmgr
	i3blocks
        i3lock
      ];
    };
  };

  hardware.logitech.enable = true;
  hardware.logitech.enableGraphical = true;

  hardware.opengl = {
    enable = true;
  };

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {

    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    # Enable this if you have graphical corruption issues or application crashes after waking
    # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead 
    # of just the bare essentials.
    powerManagement.enable = false;

    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.kraktoos = {
    isNormalUser = true;
    description = "Kraktoos";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [];
  };

  # Enable automatic login for the user.
  services.getty.autologinUser = "kraktoos";

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    neovim
    htop
    steam
    xfce.thunar
    alacritty
    starship
    floorp
    git
    vscode
    wget
    curl
    pulseaudioFull
    pavucontrol
    dunst
    libnotify

    beeper
    discord
    #exodus
    thunderbird
    flameshot
    mullvad-vpn
    obsidian
  ];

  fonts.packages = with pkgs; [
    jetbrains-mono
    (nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
  ];

  programs.starship.enable = true;

  environment.pathsToLink = ["/libexec"];

  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;
  };




  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  networking.nameservers = ["1.1.1.1" "1.0.0.1"];
  # networking.enableIPv6 = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "24.05"; # Did you read the comment?

}

Also, whenever I try to curl a website that the error is currently in i get:

curl: (6) Could not resolve host: [...]

I think I solved it. I still don’t know what the issue was but putting this into my config worked for me.

networking = {
    hostName = "krakpc";
    #networkmanager.enable = true;
    useDHCP = false;
    interfaces.enp7s0 = {
      useDHCP = true;
      ipv4.addresses = [ {
        address = "192.168.1.69";
        prefixLength = 24;
      } ];
    };
    defaultGateway = "192.168.1.254";
    nameservers = [ "1.1.1.1" "8.8.8.8" ];
    #enableIPv6 = false;
    dhcpcd.extraConfig = "nohook resolv.conf";
  };

Glad you found a workaround!

OMG thank you, I had the same problem just now, and it worked.:raised_hands:

Thank you from the bottom of my heart! Works for wireless networks as well.

For anyone coming here from Google, the relevant part of the solution is this:

# Enable DHCP for specific interfaces only.
-networking.useDHCP = lib.mkDefault true;
+networking.interfaces.enp3s0.useDHCP = lib.mkDefault true;

This change resolved the following issues for me:

  • I was unable to connect to certain websites via HTTPS (in all browsers, even using curl).
  • I was unable to connec to to certain hosts via SSH (stuck at debug1: expecting SSH2_MSG_KEX_ECDH_REPLY)
  • GitHub Copilot stopped working in my JetBrains IDEs