Hyprland crashed or you restarted it, everything looks fine, and then you reattach to a tmux pane and run hyprctl monitors and get a socket error. The socket path in the error has your old instance signature, not the new one.

Couldn't connect to /run/user/1000/hypr/0002f148c9a4fe421a9d33c0faa5528cdc411e62_1772832671_1697803855/.socket.sock. (4)

The reason is that Hyprland identifies itself with HYPRLAND_INSTANCE_SIGNATURE, an env variable set at startup. When it crashes and restarts, it generates a new one. Your tmux panes were started before the crash, so they still have the old value in their environment.

You might know about update-environment in tmux. Adding HYPRLAND_INSTANCE_SIGNATURE there does update tmux’s internal env table when you reattach, but it does not push the value into shells that are already running. Those processes have their own copy, set at the time they were spawned, and tmux cannot reach in and change it.

The fix is to not rely on the env variable at all inside your shell. Instead, resolve it dynamically every time hyprctl is called, by looking at what Hyprland actually wrote to disk.

In fish, you wrap hyprctl with a function. Fish loads functions from ~/.config/fish/functions/ automatically, so a file named hyprctl.fish there will shadow the real binary:

function hyprctl
    set -lx HYPRLAND_INSTANCE_SIGNATURE (command ls -t $XDG_RUNTIME_DIR/hypr/ 2>/dev/null | head -1)
    command hyprctl $argv
end

ls -t sorts by modification time, so the most recently touched directory, which is the running instance, comes first. command hyprctl calls the real binary, bypassing the wrapper so you don’t recurse.

In bash the same idea, as a function in your .bashrc:

hyprctl() {
    HYPRLAND_INSTANCE_SIGNATURE=$(command ls -t "$XDG_RUNTIME_DIR/hypr/" 2>/dev/null | head -1) \
        command hyprctl "$@"
}

One thing worth noting for both shells: ls might be aliased to something like eza or lsd. Those tools don’t always behave the same way with -t and you’ll get garbage back. command ls bypasses any alias or function and calls the real binary directly, so use that.