I'm using emacs 26.1 (although I don't think this is a new issue with this verison).

Note - this is not the GTK bug which results in the daemon crashing if X Connectivity is lost. I am aware of that bug and the workaround (specify lucid, motif or no toolkit at compile time rather than GTK).

The GTK issue happens every time you close down an emacsclient session - either gracefully or because of connectivity loss.

My issue is that the daemon will still crash when you exit the ssh session from which the emacsclient session started. Which somewhat defeats the object of having a daemon.

So you can start ssh -X [email protected] (or however you connect), you can then use emacsclient -c -n, and kill and recreate emacsclient sessions as many times as you like (this would die on GTK).

But as soon as you kill the parent ssh session, the logout process typically freezes, and when you kill it with ^C or similar the daemon crashes.

At first I thought this was an issue with either the terminal emulator (mintty) or the X Server I was using (ming, or cygwin's own). However I have now observed this behaviour on native Kubuntu 17.10, so it's nothing to do with Windows.

The issue is annoyingly sporadic - it doesn't happen every time I exit ssh - but it's fairly common.

I can find reference to what I think is the same issue here, in rson's comment. The answer given doesn't help - there should be no need to run --daemon inside a tmux session. If you execute standard emacs inside a tmux and use M-x server-start, just to labour the point, then emacs hangs after disconnecting any ssh session where an X emacsclient has been started from.

Finally note that this is specifically an X-Window issue. If I start a daemon, and connect to it using emacsclient -nw switch I can connect and disconnect the parent ssh session as many times as I want in terminal mode.

This is basically forcing me to remain in terminal mode for all my work, as having a reliable daemon is more important than the nice stuff I miss from having a proper windowing system. I'm hoping someone else has seen this or can offer any advice on diagnosing further - it's driving me crazy :-)

  • 1
    Likely Bug#11676 - Daemon crashes when ssh dies (see also merged reports).
    – npostavs
    Commented May 5, 2019 at 4:17
  • I never experienced this the way I start my emacs: emacsclient -t -q file.txt 2>/dev/null, it automatically launched daemon if there not any working on the background. In order to do that add following into .bashrc: export ALTERNATE_EDITOR=""; export EDITOR=emacsclient
    – alper
    Commented Aug 26, 2020 at 14:37

1 Answer 1


Maybe too heavy-duty to count as an answer, but since I never see this issue I'm wondering if the reason is that I use GNU Screen on all hosts I connect to and from using SSH. I invoke emacsclient on all of them, connecting to my one shared built-with-Lucid Emacs server, opening frames on the X server I'm sitting at. Thus screen effectively separates my emacsclient invocations from my ssh sessions.

So it's a guess, but I think a very good one, that running screen/tmux on all your hosts would get you out of your hole.

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.