So, I'm trying to set up emacs as a server but I'm having trouble getting it to work from the terminal. If I run emacs --daemon on some terminal I can connect to it if I run the emacsclient from that same terminal, but if I open a new terminal the emacsclient will not find the server. Things seem to work well if I run emacsclient from the launcher.

I am running

emacsclient -a '' -t

The client says:

emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

Any ideas of what could be happening?

I am using ubuntu 17.04 with gnome/i3 if that matters.

5 Answers 5


I used to have the same issue until I did:

alias e="emacsclient -t --socket-name=/tmp/emacs1000/server"

And now I just use this "e" alias to start emacsclient.

I haven't seen the issue since.

  • 1
    This worked, how do I tell the server to start the /tmp/emacs1000/server ? (the first client is starting it for me) Sep 27, 2017 at 18:04
  • Before running an emacsclient, I always first start the emacs server as emacs --daemon and it always starts listening on that /tmp/emacs1000/server socket automatically. I'm sure there's a less hacky way to do this that doesn't involve hardcoding the /tmp/emacs1000/server location in the e alias, and would always work no matter where the socket is created by the server (and that is probably how emacsclient is intended to work when invoked without the --socket-name option), but doing it this simple hackish way always worked for me.
    – izkon
    Sep 27, 2017 at 18:23
  • @MatíasGuzmánNaranjo Using command like lsof -w -c emacs | grep 'server' you'll know what the exact socket-name is, and if you are using emacs-28, you'll notice that the socket-name is not /tmp/emacs1000/server anymore, it is /run/user/1000/emacs/server
    – CodyChan
    Dec 11, 2020 at 13:51
  • mine is under /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.1.0 is it normal?
    – alper
    Mar 3, 2021 at 23:09

Make sure you are using the same version of emacs and emacsclient.

When my system emacsclient is used instead of my custom build emacs, I'm getting a similar error:

$ /usr/bin/emacsclient --version
emacsclient 22.1

$ /usr/bin/emacsclient .
/usr/bin/emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

With the correct version:

$ /usr/local/bin/emacsclient --version
emacsclient 26.0.50

$ /usr/local/bin/emacsclient .
Waiting for Emacs...
  • 1
    This solves my problem
    – xtt
    Dec 10, 2017 at 15:24
  • Yes that solves mine too. I just recently upgrade my emacs version from 25 to 27, but the emacsclient link was pointing to the old version. So sudo update-alternatives --config emacsclient to update the links.
    – ABu
    Dec 24, 2020 at 13:04

For unfathomable reasons, this just happened to me on a FC28 upgrade of my laptop. Even stracing ddid not help. After perusing several links (this included), I came up by sticking these lines:

# bash syntax
# On laptop, emacscclient cannot find emacs socket any longer (after FC28)
export EMACS_SERVER_SOCKET=${TMPDIR:-/tmp}/emacs$(id -u)/server
alias emacsclient="/usr/bin/emacsclient -s $EMACS_SERVER_SOCKET"

Which does not hardcode the '1000' part (which just happpens to be the id of the first user created on this particular machine, duh), and accounts for TMPDIR. Exporting EMACS_SERVER_SOCKET is cute, but useless, as emacsclient does not allow that to be configured from an env var (unreasonably, IMHO).

If full control is preferred, one can put:

(setq server-socket-dir "~/.emacs.d/server-dir") 

somewhere before server-start in their .emacs, and use "~/.emacs.d/server-dir/server" as the server socket name for the above mentioned alias. server-dir will be automatically created, with the right permissions 0700, if it does not already exist.


Not necessarily the answer you are looking for, but I have in exactly the same setup always used just emacsclient -c or emacsclient -t. Meaning I don't start the server manually, the first invoking of either will start the server and any subsequent invoking will connect to the server.

  • This works for me, but again, within each specific terminal. So, if I start a new terminal, it will start a new server. Sep 17, 2017 at 14:20
  • Do you have any server specific stuff in your .emacs? If so, I'd comment it out and try again. Otherwise I am out of ideas.
    – gaussian
    Sep 17, 2017 at 14:24
  • Also: which version of Emacs you are running? My setup works with both Emacs25 (25.1) from the Ubuntu depo and self-compiled Emacs25.2.
    – gaussian
    Sep 17, 2017 at 14:40
  • I don't think I have anything in the init file. I am running 25.3, but the same happened with 25.2. Also, launching the server with emacs -q --daemon does the same thing. Sep 17, 2017 at 14:43
  • Out of ideas, sorry. Works in my setup, even with emacs -q --daemon.
    – gaussian
    Sep 17, 2017 at 14:49

Create a script say "myemacs" as below:

emacsclient -a '' -c "$@"

Run it will create daemon if not exist, and will connect to daemon if daemon exist.

  • This does not work. I get the same problem, If I launch it from two different terminals it creates a new daemon each time. Sep 19, 2017 at 15:38
  • @MatíasGuzmánNaranjo Oh, but I saw you are using "-t", I am using "-c". Did you try "-c" also?
    – lucky1928
    Sep 19, 2017 at 18:56
  • that doesn't change anything, it's the same behavior with either -c or -t. The client just can't find the server. Sep 19, 2017 at 20:45
  • this does not work
    – alper
    Feb 23, 2021 at 14:24
  • I can confirm this does not work. The problem stems from the fact that --server-name is not set and -a '' is present. In recent versions of emacsclient this means starting a new emacs in daemon mode. Jan 5, 2022 at 23:33

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.