So, I have tmux session running on my local machine, but I can only connect to it (or see information about it) if I ssh back to myself first:
% tmux ls
failed to connect to server: Connection refused
% ssh localhost -t tmux ls
Password:
0: 2 windows (created Mon Nov 26 12:47:44 2012) [208x52] (attached)
Connection to localhost closed.
This isn’t the worst hoop to have to jump through, but why is it happening, and how can I fix it?
For its client/server communication, tmux uses a named socket (in a UID-based subdirectory) under the directory specified by the TMPDIR environment variable. If this environment variable is not set (or it is empty), then tmux uses the directory defined by
_PATH_TMPfrompaths.h; this is often/tmp.Note: The following uses of “session” refer to login sessions, not tmux sessions.
My guess is that your ssh sessions share a common TMPDIR value (possibly not having one at all), while your “normal” sessions use a different TMPDIR value. Since the TMPDIR values are different in your different sessions, a client in one session type can not directly “see” a server started in the other session type (e.g. the client tries using
/var/folders/random/directories/tmux-500/default, but the server is listening at/tmp/tmux-500/default).To fix the problem you can simply adjust your TMPDIR to match whatever it normally is in your ssh sessions:
You can determine the path your client is trying to use like this:
This will create a evanescent server using a socket named
tempinstead ofdefault, and show you the path to the socket it is using.