2

I was running Emacs in daemon server mode when my computer was force rebooted. After reboot was complete, I could not start the Emacs server again, receiving the error message:

Starting Emacs daemon.
Unable to start the daemon.
Another instance of Emacs is running the server, either as daemon or interactively.

How do I remedy this?

holocronweaver
  • 1,359
  • 10
  • 22
  • 2
    C-h f server-start says: To force-start a server, do M-x server-force-delete and then M-x server-start. – NickD Mar 30 '22 at 18:42

1 Answers1

5

To prevent multiple daemon sessions with the same name running, Emacs daemon server uses a lock file. Normally when the daemon stops (say by running kill-emacs), it deletes this file as part of cleanup, but in the case of a forced PC restart or shutdown (say via power loss) the lock file may remain despite no daemon running. This will prevent a new daemon from starting.

There are a few ways to resolve this.

Solution #1: start up Emacs without a daemon, run M-x server-force-delete to delete the lockfile, then start the daemon (say via M-x server-start).

Solution #2: delete the lockfile, typically stored under ~/.emacs.d/server/server or /run/user/<uid>/server. (The exact name of the lockfile may differ if you name your sessions.)

holocronweaver
  • 1,359
  • 10
  • 22