Is it possible to have eglot use a language server running on my local machine to work on files on the remote machine?

I'm trying to edit TypeScript files on a remote server. I can visit the file just fine via TRAMP, and I can run commands like prettier on that buffer using the remote node modules. I'd like to avoid having to run the language server on the remote machine if possible, but this may be misunderstanding how TRAMP works.

1 Answer 1


You will need to run the LSP server on the machine where the source code is, because the LSP protocol is predicated on the server having access to all of the source code at once, as files on disk.

I don’t see much documentation about it, but I am given to understand that if you open your source code via TRAMP then Eglot will simply search the remote host for the LSP server program, rather than your own computer. If it finds it, it will simply run it there on the remote host as expected.

Alternatively, most LSP servers can be set up to run as a service that listens on a TCP port. You could configure your LSP server as a service on the remote host, and then configure Eglot to connect to that port instead of trying to run a program. You would probably also need to configure SSH to enable local forwarding to that port over your ssh connection. The LSP protocol is not itself encrypted or authenticated, so you wouldn’t want to allow just anyone to connect to it; don’t allow that port through your firewall.

  • 1
    "the LSP protocol is predicated on the server having access to all of the source code at once" is the context I was misunderstanding. Thanks!
    – Evan Davis
    Commented Mar 17, 2023 at 18:33
  • You’re welcome!
    – db48x
    Commented Mar 18, 2023 at 2:29

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.