切换到WSL2.0后无法连接到x-server Unable to init server: Could not connect: Connection refused无法显示窗口

之前通过安装vcxsrv-64.1.20.9.0.installer.exe,

启动x-launch服务器后

无法通过bash打开显示窗口

错误:

Unable to init server: Could not connect: Connection refused
(gedit:2705): Gtk-WARNING **: 17:54:46.065: cannot open display: :0.0

原因可能是WSl2.0变动后,无法连接到服务器

需要更改~/.bashrc文件

sudo vim ~/.bashrc

#输入下面一行,下面为windows系统IP地址
export DISPLAY=192.168.0.103:0

#退出后 输入bash命令 生效
source ~/.bashrc

然后打开x launch服务器端

注意 取消access control!!!

点击next,然后finish。

重新尝试打开,比如gedit ~/.bashrc

成功打开窗口!

猜你喜欢

转载自blog.csdn.net/li4692625/article/details/112551555
今日推荐