# WSL mrview, could not connect to any X display

**URL:** <https://community.mrtrix.org/t/wsl-mrview-could-not-connect-to-any-x-display/4775>\
**Category:** Uncategorized\
**Created:** [April 17, 2021, 12:18pm UTC](https://community.mrtrix.org/t/wsl-mrview-could-not-connect-to-any-x-display/4775 "2021-04-17T12:18:22Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![NicDC](https://community.mrtrix.org/user_avatar/community.mrtrix.org/nicdc/32/1779_2.png) [@NicDC](https://community.mrtrix.org/u/NicDC)\
**Post date:** [April 22, 2021, 11:38am UTC](https://community.mrtrix.org/t/wsl-mrview-could-not-connect-to-any-x-display/4775/4 "2021-04-22T11:38:25Z")

</div>

Dear Liu,

This is what has worked for me:

if you are using WSL2, add these lines to you ~/.bashrc

```auto
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=0

```

If you use WSL, then replace export DISPLAY=:0 instead.

Install [VcXsrv](https://sourceforge.net/projects/vcxsrv/) and change your firewall settings to allow all incoming connections to vcxsrv (create new rule and add vcxsrv.exe to allowed applications). Launch an X session (Mutiple windows, display number: -1 → start no client → unselect native opengl, select disable access control → finish).

Restart your WSL/WSL2 session and you should have mrview working.

As an alternative to using VcXsrv, you can install MobaXterm and if you launch your WSL2/WSL session from there, it should work out of the box (after configuring firewall access to the MobaXterm executable).

Hope it helps,  
Nick

---

_[View the full topic](https://community.mrtrix.org/t/wsl-mrview-could-not-connect-to-any-x-display/4775)._
