112

I just installed tmux (a terminal multiplexer) with homebrew. When I try to run it, it always exits with [exited] Nothing shows up.

When I try to run tmux list-session I get an error:

failed to connect to server: Connection refused

I tried running tmux start-server, but again nothing happens.

What can I do?

7
  • 2
    start using the -v option to increase verbosity Mar 5 '12 at 17:03
  • 3
    Check your default-command and default-shell options. If tmux is having trouble running your default command (or shell) it will respond like you are describing. For further investigation, you can use do something like tmux new /bin/zsh to explicitly start with (e.g.) /bin/zsh instead of relying on default-command or default-shell. Mar 6 '12 at 7:18
  • 3
    tmux new /bin/zsh worked for me. Thank you.
    – Stevens
    Mar 10 '12 at 15:13
  • Er, my suggestion was meant as a diagnostic step, not a final workaround. There is probably something buggy about your default-shell or default-command setting. Mar 15 '12 at 11:58
  • I recently found (for the first time) that if 1) .tmux.conf exists but has syntax errors or 2) .tmux.conf is a symbolic link that links to nothing, tmux will not open. It might be good to try at first with the default configuration file so first mv $HOME/.tmux.conf $HOME/.tmux.conf.backup and see if tmux starts. @ChrisJohnsen is right, your solution simply means that there is a bug afoot. Apr 3 '12 at 5:16
197

I had this same problem. It was caused by having set-option -g default-command "reattach-to-user-namespace -l zsh" in my .tmux.conf without having reattach-to-user-namespace installed.

The fix was to install "reattach-to-user-namespace" via Homebrew (brew install reattach-to-user-namespace)

8
  • 2
    great thx! Exactly what was missing on my system to make it work!
    – DannyRe
    Sep 4 '12 at 23:24
  • 1
    +1 Thanks a ton! I had exactly the same issue. Do you know any way to set options conditionally so it won't fail on a system that doesn't have reattach-to-user-namespace installed? May 8 '13 at 8:16
  • 2
    @padde See this solution.
    – jrhorn424
    Oct 10 '13 at 22:16
  • Any idea how to achieve this in Ubuntu? Tried looking for a way to download reattach-to-user-namespace but my efforts were futile.
    – DaMainBoss
    Nov 23 '13 at 5:32
  • @DaMainBoss reattach-to-user-namespace is for tmux only. If you're on ubuntu just comment out that line from your .tmux.conf file
    – pho79
    Feb 22 '15 at 3:41
48

In my situation I had been fiddling with a number of dotfiles so expected things to be amiss. My fix happened to be shutting down tmux with killall tmux. After this I was able to spin up properly.

3
  • 2
    This worked for me, I already had reattach-to-user-namespace installed
    – diek
    Apr 30 '20 at 20:47
  • 2
    worked for me. i did not have anything related to "reattach-to-user-namespace" in my conf
    – mepler
    Oct 26 '20 at 23:08
  • 4
    I suspect this is related to @mhansen's answer about it happening when updating tmux. I believe I updated tmux via Homebrew and then ran into this. Worked after "killall tmux". Presumably the old version of tmux still had sessions open causing this issue. For google-ability, the full error output for me was "[exited] ^[[?62;4c^[[ITERM2 3.4.4n".
    – Henrik N
    Mar 22 at 20:38
7

Do make sure that the default-shell option only contains the executable path and does not contain options.

In /etc/tmux.conf or ~/.tmux.conf

set-option -g default-shell "/bin/bash"
set-option -g default-command "bash -l"
set-option -g default-path $HOME
set-option -g default-terminal "screen-256color"
1
  • This answer led me to the real reason, I had just uninstalled tcsh, and my default shell and default command were still set to it. Changing it to /bin/ksh, or a default installed shell of your choice, fixed it for me. Aug 20 '16 at 22:02
4

This happened to me just after updating tmux, while I still had an old version of tmux running.

If you've just updated tmux, quit all the running tmux sessions and it should work again.

1

If you're using a script to wrap reattach-to-user-namespace, as outlined by jimeh, don't forget to make the script executable with chmod +x ~/bin/login-shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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