Skip to content

Instantly share code, notes, and snippets.

@tydel
Last active July 16, 2025 06:59
Show Gist options
  • Select an option

  • Save tydel/679a5d1903ec3e393d82417b5a688bc1 to your computer and use it in GitHub Desktop.

Select an option

Save tydel/679a5d1903ec3e393d82417b5a688bc1 to your computer and use it in GitHub Desktop.
How to recover an orphaned tmux session

How to recover an orphaned tmux session

Introduction

I don't know how common this issue is, but I run into an issue occasionally on sdf.org where I have a tmux server instance running (as evidenced by the process list) however the server's socket in /tmp is gone/deleted/missing so I'm unable to attach a tmux client to it.

Problem

tmux-server process is running, but there is no socket file to connect to

When attempting to re-attach to the session using tmux a, you get an error stating there are no sessions:

$ tmux a
no sessions

When viewing the process list, you can see that there is a session process running:

$ ps aux | grep ^tydel.*tmux
tydel         19445  0.0  0.0   33464   4184 ?        Ss   18May25   21:48.43 tmux: server (/tmp/tmux-57611/default) (tmux)

But the referenced socket location is not present:

$ ls -l /tmp/tmux-57611/default
ls: /tmp/tmux-57611/default: No such file or directory

Solution

Send a USR1 signal to the tmux server process (kill -USR1 <pid>)

This will force the process to re-write it's socket file and you can go about re-attaching as you do normally!

`$ ps aux | grep tydel.*tmux`
tydel         19445  0.0  0.0   33404   4176 ?        Ss   18May25   21:48.57 tmux: server (/tmp/tmux-57611/default) (tmux)

We identified that the PID is 19445, so send the signal:

$ kill -USR1 19445

Now we can re-attach the session:

$ tmux a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment