Vim does not connect to a clientserver, which causes issues using VimTex and zathura. Upon opening any file in an Ubuntu terminal, the following error is displayed:

Error detected while processing /root/.vimrc:
line   21:
E240: No connection to the X server
Press ENTER or type command to continue    

Steps to Reproduce

This is my .vimrc file:

  1 filetype on
  2 filetype plugin on
  3 filetype indent on
  4 syntax enable
  6 call plug#begin()
  7 Plug 'lervag/vimtex'
  8 Plug 'preservim/nerdtree'
  9 call plug#end()
 11 set nocompatible
 12 set number
 13 set tabstop=4
 14 set laststatus=2
 16 let g:vimtex_view_method = 'zathura'
 17 let g:vimtex_quickfix_mode = 0
 18 let g:vimtex_compiler_method = 'latexmk'
 20 if empty(v:servername) && exists('*remote_startserver')
 21   call remote_startserver('VIM')
 22 endif

From here, open any file in the terminal, with commands such as

vim .vimrc


vim text.tex

and the error message from above will appear.

System Info

I use Ubuntu as available in the Windows Store of Windows 11 Pro. Here is the system info prompted from Vim:

  1 System info:
  2   OS: Ubuntu 22.04.2 LTS
  3   Vim version: VIM 8.2 (1-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919)
  4   Has clientserver: true
  5   Servername: undefined (vim started without --servername)

Thank you in advance!

  • 2
    I understand that you are using WSL which only allow to use console application by default. Did you do something to address that limitation? Without X server I suppose Zathura can't start. Apr 23, 2023 at 4:41

2 Answers 2


Resolved: Following Vivian De Smedt's comment, I realized I hadn't addressed such a limitation of WSL. I followed the instructions on this article from Medium entitled "Using WSL-2 with X-server — Linux on Window" and can now connect to the X-Server.

Thank you so much! I'm quite new to Vim and found this very helpful.

EDIT: In case of link rot:

  1. I installed VcXsrv, then in the properties -> shortcut -> target, I entered "C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto
  2. I entered netstat -abno|findstr 6000 into Windows Powershell
  3. I installed terminator with sudo apt-get update and sudo apt-get install terminator,
  4. I validated terminator by entering DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 terminator & into Ubuntu
  5. I allowed VcXsrv all connections in Windows Firewall
  6. I added this to my .bashrc file: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
  7. I started VcXsrv with access control disabled.

Afterwards, Vim could connect to the X-Server.

  • 1
    Welcome to Vim! Thanks for the feedback :-) Apr 23, 2023 at 15:02
  • 3
    Please edit to include instructions from the link directly (with source attribution) so that the answer stands alone in case of link rot.
    – D. Ben Knoble
    Apr 23, 2023 at 17:33
  • 1
    Maybe could you accept your answer using the v button ne t to the arrow voting buttons. It allow the question to rest :-) Apr 26, 2023 at 5:10

You must run GUI version only, i.e. gvim or vim -g. It should work under WSL, assuming you have W11 with up-to-date WSL installation.


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.