20

Every time I detach from all the tmux sessions in the terminal, after I want to get back, I get this:

[me@CentOS7 ~]$ tmux ls
error connecting to /tmp/tmux-1000/default (No such file or directory)

It seems the /tmp directory get cleared in the meantime. It doesn't happen straight away and it's hard to tell when exactly but usually after a couple of days of running I know I can't detach in order not to lose the session.

Anyone knows how to retain the session? Prevent CentOS from removing the tmux server somehow? (I assume it's CentOS as it never happened to me on Debian-based distros.)

3 Answers 3

12

You can attempt to send a SIGUSR1 to the process in order for the tmux server to recreate the socket

pkill -USR1 tmux

Source

2
  • 2
    Missed that one, thanks. Any idea why this happens on CentOS?
    – qwrtln
    Apr 9, 2018 at 6:56
  • Thanks much. I tried killing the process (SIGKILL) hoping that it would recreate the socket next time it starts. It didn't. It needed USR1 for somereason. I cant believe tmux doesn't check of missing socket and recreate it upon startup 🤦🏻‍♂️ Sep 14, 2020 at 18:40
3

Not OP's problem and kind of obvious*, but you can also get the same error message, when you are trying to list your tmux sessions in the wrong place:

E.g. in a remote shell that you opened in one of your tmux windows (e.g. by submitting an interactive job on an HPC sytem)

*) not to me 🤦🏻‍♂️

3

Below console output was done already after a restart of the computer. I tried the answer here, to no avail. What helped was to make a new session and exit it again. That seems to refresh the tmp dir.

Proof by example:

$ tmux list-sessions
error connecting to /tmp/tmux-1000/default (No such file or directory)
$ pkill -USR1 tmux
$ tmux list-sessions
error connecting to /tmp/tmux-1000/default (No such file or directory)
$ tmux -V
tmux 3.2a
$ pkill -USR1 tmux
error connecting to /tmp/tmux-1000/default (No such file or directory)
$ tmux new -s x
[exited]
$ tmux new -s y
[detached (from session y)]
$ tmux list-sessions
y: 1 windows (created Fri Nov 11 11:14:18 2022)

You must log in to answer this question.

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