Windows 10 Bash "Cannot connect to display!"

35,373

Solution 1

You need to install an "X server" to provide that graphical interface which is yet not there on a typical Ubuntu subsystem on windows 10.

If you install an X server application on your Windows desktop and change a setting in the Bash shell, applications will send their graphical output to the X server application and they’ll appear on your Windows desktop.

You can install Xming a good X server for Windows. Just accept the default settings. It will then automatically launch and run in your system tray, waiting for you to run graphical programs.

After installation you’ll need to set the DISPLAY environment variable to point at the X server already running on your system.

First run the following command in the Bash environment to set the DISPLAY variable:

export DISPLAY=:0

and then run your graphical application. In this case

suplane | suximage title="My first test" &

Some part is taken from howtogeek

Solution 2

The current best solution I have found is to download MobaXterm and use the local bash terminal through mobaXterm and all of the graphics forwarding is handled by the windows side, currently WSL doesnt handle and GUI stuff.

I was using a mac at work and a windows machine at home, I set up WSL and was trying to work with jupyter notebooks but having the same issue "Cannot connect to X server" when launching images through matplotlib even if I had the cygwin X server running the WSL was not aware of it. After a bit of digging I saw a thread recommending mobaXterm, works a treat now.

Share:
35,373

Related videos on Youtube

maezawi
Author by

maezawi

Updated on September 18, 2022

Comments

  • maezawi
    maezawi over 1 year

    I have recently installed Bash for Windows 10 (yay!). I need it to run my processing software called 'Seismic Unix' which installed fine. However, when I ran the command attached, it gave this error "Cannot connect to display!". This command is supposed to display an image on the screen, and I think the Bash cannot access my laptop screen in order to display the results.

    A screenshot of the error "Cannot connect to display!"

    screenshot

    Here is the command:

    suplane | suximage title="My first test" &

    I look forward to hearing from you, and thank you in advance.

    • Apologician
      Apologician over 7 years
      Welcome to SE. It appears you are looking for Windows support. This forum is for user running Ubuntu and having specific issues or questions about Ubuntu. You'll have to look at one of our other forums such as superuser.com for support for Windows 10.
    • maezawi
      maezawi over 7 years
      When I installed Bash inside Windows 10 I was informed it IS indeed Ubuntu command line inside Windows 10 (developed by Canonical). They have even given me an Ubuntu email address, but I forgot to write it down, so I came here.
    • Zanna
      Zanna over 7 years
      @L.D.James it has been decided in meta that WSL is on topic here
    • Apologician
      Apologician over 7 years
      @Zanna Thanks for the heads up! By the way, what is WSL?
    • Zanna
      Zanna over 7 years
      @L.D.James Windows Subsystem for Linux which is apparently the "proper" name for "Ubuntu on windows"/ "bash on windows"
  • maezawi
    maezawi over 7 years
    Thank you, souravc! I will test your solution and will share results. Is Xming something similar to Xcode? Xcode is required when we try to install the same software on Mac OS.
  • sourav c.
    sourav c. over 7 years
    No, Xcode is basically an IDE containing a suite of software development tools and OpenGL support in Apple whereas Xming is an X server for Windows. The Xming counterpart in Mac is XQuartz.
  • sourav c.
    sourav c. over 7 years
    Glad to hear that. Now you can accept the answer. It will indicate your problem is solved and you are satisfied with the answer. See how to accept answer and What should I do when someone answers my question
  • alessmar
    alessmar almost 7 years
    Another great option is MobaXterm, by default it starts an embedded X server (at least from version 10.2).
  • Damian Yerrick
    Damian Yerrick almost 6 years
    Is it worrisome that Xming hasn't been updated in a decade?
  • jdhao
    jdhao about 5 years
    @DamianYerrick, indeed it is. There is another X server for Windows called vcxsrv which is updated frequently.
  • DARKGuy
    DARKGuy over 4 years
    Interesting, can you please provide more details on how did you configure MobaXterm? and how is all the graphics forwarding handled by the windows side? I just set up WSL and Xming, but I also have a Mac at work and a Windows machine at work. What do you do - forward X from Windows to Mac? if so, can you please provide more details? Thanks!