Software⏱️ 4 min read📅 2026-06-11

How to Fix: Error: Can't open display: 0

Error Can't open display: :0 in WSL2 GUI apps on Windows 10

Quick Answer: Check if X11Forwarding is enabled and set the DISPLAY variable correctly.

The error 'Can't open display: :0' occurs when you're trying to access X11 GUI applications from within a Windows Subsystem for Linux (WSL2). This issue affects users who have installed WSL2 and are attempting to run graphical applications within the terminal. The frustration lies in the fact that the X11Forwarding feature is enabled, which should allow for seamless interaction between WSL2 and the host machine's display.

Fortunately, this error can be resolved by identifying and addressing the root cause of the issue. In most cases, the problem arises from incorrect settings or conflicts with other applications.

⚠️ Common Causes

  • The primary reason for this error is that the DISPLAY environment variable is not correctly set within WSL2. When you execute the 'export DISPLAY=:0' command, it sets the display to ':0', but if this value does not match the display number of your host machine's X11 server, the system will fail to open the display.
  • Another possible cause could be related to the Xming application being run in 'No client' mode. This setting prevents Xming from using a window manager and instead uses a virtual desktop to render the GUI applications. However, if this setting is not properly configured or conflicts with other applications, it may lead to issues like the 'Can't open display: :0' error.

🛠️ Step-by-Step Verified Fixes

Configuring DISPLAY Environment Variable

  1. Step 1: Open a terminal in WSL2 and execute the command 'export DISPLAY=:0'. This sets the display environment variable to ':0', which should match the display number of your host machine's X11 server. You can find the display number by running the command 'xrandr' on your host machine.
  2. Step 2: If you are using a virtual desktop or window manager with Xming, ensure that it is properly configured and not interfering with the DISPLAY environment variable. You may need to adjust settings or run additional commands to resolve any conflicts.
  3. Step 3: After configuring the DISPLAY environment variable, try running GUI applications again by executing the command 'xeyes'. If you encounter the 'Can't open display: :0' error, proceed to the alternative fix method.

Adjusting Xming Settings

  1. Step 1: Open the Xming settings window and ensure that the 'Use virtual desktop' option is disabled. This setting can interfere with the DISPLAY environment variable and lead to issues like the 'Can't open display: :0' error.
  2. Step 2: Additionally, verify that the 'X11Forwarding' feature is enabled in your WSL2 configuration. You can check this by running the command 'xhost -display :0'. If X11Forwarding is not enabled or is set to a different value, you may need to adjust it to resolve the issue.

💡 Conclusion

To summarize, the 'Can't open display: :0' error in WSL2 can be resolved by correctly configuring the DISPLAY environment variable and adjusting Xming settings. By following the steps outlined above, you should be able to successfully access GUI applications within your WSL2 terminal.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions