Ever tried to attach to a running tmux session, only to find that that fails?
tmux attach # no sessions tmux ls # error connecting to /tmp/tmux-1000/default (No such file or directory)
Even though you're sure tmux is running fine, it shows up as running in your task manager after all.
So, where are your precious tmux sessions?
All your tmux sessions are hosted by a single tmux process. This is persistent and keeps running until you quit all sessions again.
The process creates a socket file, other processes use this to talk to it. When
tmux attach, the program finds this socket and attaches to it
through the socket.
Now, what happens when you delete this file? Exactly, your
tmux command doesn't
know how to connect to the running server. That's what we're seeing here.
Because others had the same issue, tmux provides a feature to fix this. When you
SIGUSR1 signal to the host process, it creates a fresh socket file
For this, you need to find the PID of the running tmux server. Find it through your task manager, or invoke the following command to find the PID of the oldest running tmux process:
pgrep --oldest tmux # 5612
For me it was
5612, so I invoke the following and attach it again (be sure to
use your own PID):
sudo kill -SIGUSR1 5612 tmux attach