I have (server-start) in my .emacs file and set the variables HOME, ALTERNATE_EDITOR (=runemacs.exe) and EMACS_SERVER_FILE set.

When I start

emacsclientw.exe  test.txt

the first time, I expect emacs to start and display the buffer test.txt What happens is that emacs is started and the buffer scratch is displayed, the messsage line says (New file) and the buffer test.txt exists, but is not yet displayed. (That's not really what is bothering me right now)

When I now execute

emacsclientw.exe test2.txt

I expect that the same emacs is used and a new buffer test2.txtis created.

But what happens is that a new emacs is started with an open warning buffer reading:

Warning (server): Unable to start the Emacs server.
There is an existing Emacs server, named "server".
To start the server in this Emacs process, stop the existing
server or call `M-x server-force-delete' to forcibly disconnect it.

This sounds to me as if the first instance starts a server, but the second does not connect to it but instead tries to start server again.

What could be the problem?


I had the same problem. Currently, I used the following solution.

Add to your .emacs file:

(load "server")
(unless (server-running-p) (server-start))

The solution comes from How to start emacs server only if it is not started?


You should start Emacs using


After that you can use

emacsclientw.exe  test.txt
  • Thanks, but -- Nope, it has the same effect. And if it would work, it would not be what I need, since I will have to start emacs always in the same way..
    – Titule
    Sep 26 '11 at 15:48

From the looks of it, your emacs server is creating its server file in a place where emacsclientw cannot find. To debug the issue further, you can run emacs, and see that the server file specified in EMACS_SERVER_FILE is indeed created.

In my setup, the only environment variable I use is HOME. The custom variable server-name is left at its default value (i.e. server). This causes the file $HOME/.emacs.d/server/server to be created when I run emacs. And since this location is the default, emacsclientw.exe is able to locate this file, and determine how to talk to emacs.

I had a quick look at server.el in my system, and I couldn't see anything about EMACS_SERVER_FILE in it. If you use a non-standard location, that might be the cause of your problems.


If you alread have (server-start) in your .emacs file, you might want to check The Emacs Wiki. It has some good information about using emacsclient under MS Windows.

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.