45

I have installed tmux from source on my localspace in Fedora. It was working nicely so far. But suddenly can not run it anymore, when run tmux, it just halts. Tried different command options like ls-sessions, none works. Killed all the processes of my user, deleted all the files of tmux and libevnet, and reinstalled them again from scratch. Still same, and tmux command in terminal just freezes without any actual error.

1

9 Answers 9

79
+50

I had faced this problem for a long time and after a bit of searching I figured out that this was being caused because I accidently hit Ctrl+S (Ctrl+A+S is my shortcut for switching panes), and this turns off flow control in terminals and stops the terminal from accepting input. It can be reenabled by pressing Ctrl+Q.

Source: https://superuser.com/a/553349/137226

1
  • This saved my session!
    – Louis Yang
    Commented Dec 4, 2023 at 0:47
48

Had a similar issue, where I had a tmux session with two buffers. I didn't see anything I typed, but when I switched between buffers what I had typed previously would appear onscreen. stty sane didn't work.

I detached Ctrl-b+d, and noticed that there was still a client attached when I looked at tmux list-clients. tmux detach-client removed it, and then I could reattach and the everything worked again.

3
  • 3
    Wow! that solved a problem I encounter too often... thanks Commented Nov 22, 2016 at 12:37
  • Was the extra client a fluke?
    – John P
    Commented Dec 19, 2017 at 8:07
  • Thank you!!!! You are single who gave right answer. Commented Aug 6, 2020 at 15:52
20

If it is ok to lose your sessions, try deleting the tmux-NNNNNNN directory, where NNNNNNN is a number, under your /tmp directory. According to the tmux manual, if the TMPDIR environment variable is set, the tmux-NNNNNNN will be put in the TMPDIR.

tmux stores the server socket in a directory under /tmp (or TMPDIR if set);

This solved my problem of not being able to run tmux commands that are related to sessions. I also tried the following, but they did not work:

  • killall -9 tmux
  • reinstall tmux
  • restart shell session

I could not easily restart the operating system, because it's a shared server managed by others.

2
  • 1
    This worked for me as tmux was hanging as soon as I was trying to launch it in terminal. Commented Jan 24, 2020 at 15:55
  • 1
    Deleting the /tmp/tmux-NNNNNNN folder helped. Thanks.
    – wedesoft
    Commented Mar 18, 2020 at 10:11
10

tmux was halting right after I started it. Ctrl-Q and Ctrl-C didn't do anything.

Fixed with

killall -9 tmux

(May be a different problem, but this question showed up in Google.)

3
  • 1
    tmux was running here since Nov 8 (5 weeks), only kill -9 did help too. ps waxl showed it was in a deep sleep: 1 3605 16359 1 20 0 33004 4156 n_tty_ Ss ? 41:37 tmux. Do you remember your flags?
    – ott--
    Commented Dec 16, 2015 at 17:07
  • Nope. But I will check ps waxl next time this happens.
    – the
    Commented Dec 16, 2015 at 18:48
  • At least get a stack trace. Otherwise killing it is as much of a fix as shutting off the computer. If you expect it to happen again - which you probably should - you can also configure Tmux to log its buffer to a file so you can do a bit of a post-mortem.
    – John P
    Commented Dec 19, 2017 at 8:16
8

I had the same issue. The cause is that the tmux buffer is full, and it also may happens cause of multi clients to the tmux session.

To solve it you need to detach all the clients from the session, and reattach it.

The best way I found to solve it is to add to the ~/.bashrc file this functions:

check_params() {
       if [[ $1 < $2 ]]; then
               echo -e "Usage:\n${3}"
               ok=0
       else
               ok=1
       fi

}

# detach all the clients from this session, and attach to it.
reattach_client() {
       check_params $# 1 "reattach_client <tmux_session_name>"
       if [[ $ok == 1 ]]; then
               tmux list-client | grep $1 | awk '{split($1, s, ":"); print s[1]}' | xargs tmux detach-client -t | true
               tmux attach -t $1
       fi
}

then run source ~/.bashrc to make these changes in the terminal.

Now to attach the session type:

reattach_client <session_name>

solved my issue.

Thanks to Alex Zelichenko for help me with this!

3
  • I had two tmux sessions which where working fine, but any tmux command in a new shell hanged. Detaching from the running tmux sessions solved the problem. Thanks.
    – Daan
    Commented Apr 17, 2020 at 7:41
  • What if you don't know the session name? Commented Apr 5, 2023 at 17:58
  • You can list the sessions with the command: "tmux list-sessions" or with the shortcut "tmux ls". Good luck.
    – Rea Haas
    Commented Apr 12, 2023 at 19:39
3

You should be able to narrow down your problem a bit with a few of these tests:

  1. Give it a shot from outside X11: Ctrl+Alt+F2 (or use ssh from another computer)

  2. Test if other terminal emulators work: script and screen

  3. Try another complicated terminal application: htop and mc

  4. Reset your TTY settings: stty sane

  5. Check that your terminal identified: echo $TERM (it should be something like "xterm" or "linux")

  6. Make that your terminal capabilities file exists: ls -lh /usr/share/terminfo/*/$TERM

3

Thanks. I found the problem. The tmux process were in D state, and I had no choice but to reboot the system. The problem came from kerberos ticket expiring after a while. And find a scripts that solves this problem: https://iain.cx/src/ktmux/

1
  • Mine was not hanging in D state, it was just sleeping. kill -9 helped.
    – ott--
    Commented Dec 16, 2015 at 16:55
2

A less drastic action (to try before killing the tmux process) is to ssh into the machine and run the following command.

kill -CONT `pidof tmux`

Source: https://github.com/tmux/tmux/issues/507#issuecomment-271502093

1

This happened to me because I accidentally tried to create two parallel tmux sessions with the same name.

What worked for me was to enter htop, checking pid's of the two running commands that created the sessions, and killing both by using kill -9 pid1 and kill -9 pid2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.