Browsed by
Tag: xcb

qt.qpa.xcb: could not connect to display :10.0

qt.qpa.xcb: could not connect to display :10.0

miniDNServer 启动 DNS 服务需要绑定标准 53 端口,在 Linux 系统下默认需要有 root 权限(或者 sudo )才能绑定 1024 以下的端口。一般情况下都能正常运行,但是在 Pi 系统中以 sudo 方式运行时,提示以下错误:

No protocol specified
qt.qpa.xcb: could not connect to display :10.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

这个是 X11 auth 导致的问题。sudo 用户没有设置访问 x server 的权限,按以下步骤可以解决:

(1)当前正常用户执行以下命令,查看正常 cookie:

xauth list $DISPLAY

正常情况下会显示多条记录,如下所示:

raspberrypi/unix:10 MIT-MAGIC-COOKIE-1 4f8433752c1eac61313208cbf9050683
raspberrypi/unix:11 MIT-MAGIC-COOKIE-1 2c67fcb8cf523a837bedadcebad49958
raspberrypi/unix:0 MIT-MAGIC-COOKIE-1 0cd700917a92e9f330154efdd19b6acf

(2)将这些结果全部加入 sudo 的 xauth,如下所示:

sudo xauth add raspberrypi/unix:10 MIT-MAGIC-COOKIE-1 4f8433752c1eac61313208cbf9050683
sudo xauth add raspberrypi/unix:11 MIT-MAGIC-COOKIE-1 2c67fcb8cf523a837bedadcebad49958
sudo xauth add raspberrypi/unix:0 MIT-MAGIC-COOKIE-1 0cd700917a92e9f330154efdd19b6acf