In tmux session, cannot connect to X server after ssh'ing
I had the same issue. I normally use tmux
as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set $DISPLAY
. The answer by @chrisdembia works, but requires changing DISPLAY
in each new window for the rest of the tmux session, which is a pain.
A permanent solution is to remove DISPLAY
from the tmux update-environment
variable in the tmux settings. You can see your current value with this command:
tmux show-options -g update-environment
To remove it, I added this line to my ~/.tmux.conf
file, including everything but DISPLAY
:
set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why DISPLAY
is there by default, for a different common use case.
All I need to do is set the DISPLAY environment variable to :0.0. I think the issue was that I am using the fish shell, and I need to use the -x flag to set when doing this:
set -x DISPLAY :0.0