After using emacs routinely for a long time, today I suddenly have problems starting emacs: When I type emacs in a terminal window, nothing at all happens, emacs seems to be running, but does not display anything, does not open a window, and does not react to any input. This phase takes 30 seconds (nearly exactly!), and then emacs suddenly starts up. Restarting the machine made emacs work again once, but 2 minutes later the problem was back again. Details are below. My questions: How can I make emacs start again without a 30 second delay? How can I debug such problems?

Operating System: Mac OS X, version 10.11.6 (on a MacBook Air)

Emacs version: The problem occurs both with emacs 22.1.1 (system provided) and emacs 24.5.1 (installed via homebrew). I can interrupt emacs 24.5.1 (in the non-working, hanging state) using Ctrl-C. Emacs 22.1.1 seems not to react to Ctrl-C, but if I press Ctrl-G twice it suspends itself.

Illustration of the problem:

>>> time emacs --batch

real    0m30.039s
user    0m0.013s
sys 0m0.010s

Things that still work:

  • emacs --version and emacs --help work for both versions

  • The computer seems otherwise happy, for example I still can start vi

Things that don't work ("hangs" below means that the 30 second wait is present):

  • emacs -Q hangs, as does emacs -q

  • emacs -nw hangs

  • emacs --debug-init hangs

  • Emacs seems to not complain about invalid command line options, for example emacs --tri-tra-tralala just hangs with no message

  • The problem is not fixed by changing terminal emulators: emacs hangs both using the system-provided Terminal application, and using iTerm2.

  • 3
    This sounds very much like this problem. That post suggests that Emacs 25 doesn't do this. Emacs 25 isn't released yet, but apparently it can be installed through Homebrew.
    – legoscia
    Aug 5, 2016 at 20:35
  • @legoscia Just installed Emacs 25 and this solved my problem.
    – jochen
    Aug 6, 2016 at 10:44
  • Great! I posted it as a proper answer for posteriority.
    – legoscia
    Aug 6, 2016 at 11:37

2 Answers 2


Given that the problem occurs even with emacs -Q, Emacs's own debugging tools probably won't help. They're geared towards debugging Lisp problems but your Emacs hangs before problems in Lisp code get a chance to start.

You can see what a program is doing by running it under dtruss. From a terminal, run

sudo dtruss -deof emacs -Q  2>emacs.dtruss

Look at the resulting emacs.dtruss file and see what system calls took a long time. (Feel free to post the trace here if you don't understand it! This isn't meant to be comprehensible by end-users.)

  • It's not necessarily the case that problems occuring with emacs -Q can't be debugged in Lisp. Lots of Emacs is in Lisp. If C-g works, then toggle-debug-on-quit can help to debug hanging. (if C-g doesn't work, then it's likely a problem at C level, and indeed can't be debugged in Lisp)
    – npostavs
    Aug 6, 2016 at 2:19
  • @Gilles thanks, I didn't know about dtruss. (Side note: output seems to go to standard error, so I needed 2>emacs.dtruss.) The output indicates that emacs is doing something relating to DNS, which is compatible with what @legoscia is suggesting above.
    – jochen
    Aug 6, 2016 at 10:33
  • I accepted this answer, since it taught me how to debug such problems and since I cannot split the acceptance into two halves. But really, half the credit should go to @legoscia who pointed out that I can make the hang go away by installing Emacs 25.
    – jochen
    Aug 6, 2016 at 10:49

As mentioned in the etc/PROBLEMS file in Emacs 24.5:

*** Emacs startup on GNU/Linux systems (and possibly other systems) is slow.

This can happen if the system is misconfigured and Emacs can't get the
full qualified domain name, FQDN.  You should have your FQDN in the
/etc/hosts file, something like this:   localhost  nuc04.t30.physik.tu-muenchen.de nuc04

The way to set this up may vary on non-GNU systems.

According to this answer, the DNS request that caused the delay was removed in Emacs 25, so upgrading Emacs might be a simple way to fix the problem.

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.