There are two physical machines in front of me: nixos and mac.

  1. Physically typing in a terminal on nixos:

    nixos$ tmux ls
    0: 5 windows (created Thu Sep 16 19:21:38 2021) (attached)
    1: 1 windows (created Fri Sep 17 00:50:45 2021)
    2: 5 windows (created Wed Sep 22 05:37:28 2021) (attached)
    4: 1 windows (created Thu Sep 23 21:51:01 2021)
  2. Then physically typing on mac:

    mac$ ssh nixos
    Last login: Sun Sep 26 13:24:58 2021 from
    nixos$ tmux ls
    no server running on /run/user/1000/tmux-1000/default

Is there are a way to attach to the already existing tmux sessions when connecting from a remote machine?

1 Answer 1


You have to connect using the socket name.

In nixos tmux session, check the value of TMUX_TMPDIR (if undefined, use /tmp) and look if a socket file is there. If not, send SIGUSR1 to that tmux server and recheck.

When you have got the socket file, try from mac: Connect to nixos, Ensure that TMUX_TMPDIR is exactly matching & Execute tmux with that socket using -S socket-name and tmux should be able to list the existing session.
tmux -S socket-name ls

In case that does not work for some weird reason, restart the tmux session on nixos with -L socket-name and connect from mac and use -S socket-name to ensure that both are using the exact same TMUX_TMPDIR and the exact same socket file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .