Search code examples
linuxubuntuwindows-subsystem-for-linuxgedit

WSL - GEDIT Unable to init server: Could not connect: Connection refused


I'm using Ubuntu 18.04 as Windows Subsystem for Linux on my Windows 10 machine.
I've installed gedit without any errors or warnings.

But whenever I try to use the command gedit something (here something is a filename)
I get this error:

Unable to init server: Could not connect: Connection refused

(gedit:48): Gtk-WARNING **: 21:03:26.729: cannot open display:

Solution

  • You need an X server to run graphical applications like gedit. I use VcXsrv or Xming on my Windows desktops, both are very small and easy to install, but there exist other servers like Cygwin/X.

    Short instructions for VcXsrv/Xming:

    • download and install the Windows package
    • start XLaunch or Xming
    • export the DISPLAY variable in your WSL terminal and start gedit

      export DISPLAY=0:0
      gedit
      

    I have the problem that some checkboxes in gedit's preferences are not working (dconf error, I don't care), but other than that the editor is usable.

    Related: