Sometimes i work on remote machine (or several) via TRAMP. However, sometimes sessions end in such a way they cannot be reopened later.

In such situation, closing emacs results in unacceptable delays as futile failing attempts to reconnect to remote host go on; even if all buffers are killed.

How to avoid that and ensure emacs simply closes without resorting to means of sysstem process control?


Tramp offers several commands to cleanup. Try one of them

M-x tramp-cleanup-this-connection
M-x tramp-cleanup-connection
M-x tramp-cleanup-all-connections
M-x tramp-cleanup-all-buffers
  • I have been using tramp-cleanup-all-connections. It gave me nothing, seeing as it only causes tramp to try reconnecting later when here is something emacs thinks to be done with the "remote" buffer or remote current folder. And since reconnection is impossible, that only stalls the program for no purpose – Srv19 Apr 8 '17 at 10:55
  • Try M-x tramp-cleanup-all-buffers. It closes also all remote buffers, which might be in the way. – Michael Albinus Apr 9 '17 at 7:48
  • Michael Albinus wrote: M-x tramp-cleanup-all-buffers which is the correct answer. I clean buffers just before C-x C-c on Aquamacs, it works well. – J_H Aug 5 '17 at 14:52

The Tramp FAQ says:

• TRAMP does not recognize if a ‘ssh’ session hangs

 ‘ssh’ sessions on the local host hang when the network is down.
 TRAMP cannot safely detect such hangs.  The network configuration
 for ‘ssh’ can be configured to kill such hangs with the following
 command in the ‘~/.ssh/config’:

      Host *
           ServerAliveInterval 5

Does that help?

  • Even if all sessions are killed and connections cleaned up, TRAMP still tries to reopen them. I suspect that's because "current directory" is on remote host. That also causes TRAMP to try reestablishing connection when i try to change directory to local host. – Srv19 Apr 7 '17 at 6:45

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.