128

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?

Raystafarian
  • 21,743
  • 12
  • 62
  • 90
Stevens
  • 1,383
  • 2
    start using the -v option to increase verbosity – Florenz Kley Mar 05 '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. – Chris Johnsen Mar 06 '12 at 07: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. – Chris Johnsen 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. – scicalculator Apr 03 '12 at 05:16
  • I'm having this same problem. Chris, what exactly do you mean when you say there's something wrong with default-shell or default-command? I removed my tmux.conf file altogether and I'm still getting the error. – Adam Albrecht May 15 '12 at 00:39
  • @AdamAlbrecht: I just came across your comment (start your comment with @username to notify a user that is participating in the comment thread). If you are using the default values of default-shell and default-command, then you should check the value of your SHELL environment variable. tmux will attempt to start an instance of your SHELL when you do not give it a command (and default-command is empty, like it is by default). Maybe something (shell initialization file?) is setting your SHELL environment variable to a pathname that does not exist, is inaccessible, or not executable. – Chris Johnsen Jul 29 '12 at 02:24

5 Answers5

206

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)

robenkleene
  • 2,256
92

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.

IntelXDesign
  • 1,021
  • 6
    This worked for me, I already had reattach-to-user-namespace installed – diek Apr 30 '20 at 20:47
  • 3
    worked for me. i did not have anything related to "reattach-to-user-namespace" in my conf – mepler Oct 26 '20 at 23:08
  • 8
    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 '21 at 20:38
  • I received the commend field for creating a new tmux session after upgrading python from 3.7.9 to 3.12.1. Killing tmux process fixed it. – H A Feb 04 '24 at 10:54
8

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.

mhansen
  • 191
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"
JoshP
  • 2,273
  • 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. – Jason Robinson Aug 20 '16 at 22:02
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.

jrhorn424
  • 250