qt.qpa.xcb

qt.qpa.xcb: could not connect to display: rviz2 and rqt in Docker, from X11 auth to OpenGL errors, measured

qt.qpa.xcb: could not connect to display :99
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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted

That is rviz2 in a ROS 2 Docker container. The process aborts with exit code 134. rqt prints almost the same text (could not connect to display :99) and exits with code 1. Once the display problem is fixed, the next wall is usually OpenGL: Failed to create an OpenGL context, Unable to create glx visual or Invalid parentWindowHandle (wrong server or screen), repeated 100 times, then Unable to create the rendering window after 100 tries.

Short answer: Qt has nothing to do with it, and reinstalling won't help. The container can't reach an X server it is allowed to use. Three things must line up: DISPLAY must name the right display, the X socket directory must be mounted into the container, and the container must pass the X server's access check. The setup that worked on Humble, Jazzy and Lyrical gave the container a cookie file whose entry isn't tied to a hostname:

XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run --rm -it \
  -e DISPLAY=$DISPLAY \
  -e XAUTHORITY=$XAUTH \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v $XAUTH:$XAUTH:ro \
  osrf/ros:jazzy-desktop rviz2

No --network, --ipc, --privileged or QT_X11_NO_MITSHM flag was needed. If you are on a headless machine with no X server at all, run rviz2 under xvfb-run instead. QT_QPA_PLATFORM=offscreen doesn't work for rviz2.

qt.qpa.xcb: could not connect to display: rviz2 and rqt in Docker, from X11 auth to OpenGL errors, measured — measured results table
At a glance: the main measured table from this article. Full details below.

Find your error

Look for the first line that differs from the block above. Every row behaved the same on Humble, Jazzy and Lyrical unless the row says otherwise.

What you see What was wrong in my run
could not connect to display followed by nothing (empty name) DISPLAY not set in the container
could not connect to display :99 with no other line before it DISPLAY set, but /tmp/.X11-unix not mounted, or DISPLAY pointing at a display number with no socket (:0 when the server is :99)
Authorization required, but no authorization protocol specified, then could not connect to display :99 Socket reachable, but the X server rejected the client: no cookie, a cookie entry for a different hostname, or an xhost rule that the server had already dropped
libGL error: MESA-LOADER: failed to open swrast, then Failed to create an OpenGL context. BadValue (integer parameter out of range for operation) Humble only: Mesa DRI drivers (libgl1-mesa-dri) missing in the container
Unable to create glx visual, then RenderingAPIException: Invalid parentWindowHandle (wrong server or screen) No usable GLX: the X server had no GLX extension, libglx-mesa0 was missing, or (Jazzy and Lyrical) the Mesa drivers were missing
Unable to open display: then RenderingAPIException: Couldn`t open X display in GLXGLSupport::getGLDisplay QT_QPA_PLATFORM=offscreen. Qt started, Ogre still needed an X display
From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin. Lyrical only. It printed this on every display failure. The same image ran rviz2 fine once the display was reachable, so the hint was misleading in my runs

Every OpenGL failure ended the same way: the error pair repeated 100 times, then terminate called after throwing an instance of 'std::runtime_error', what(): Unable to create the rendering window after 100 tries, and exit code 134.

What I ran

The test machine is a headless Linux server with 2 vCPUs. It has no monitor and no X server, so I ran Xvfb in its own container (rvz-x) as a stand-in for the X server on a desktop. Its socket directory was bind-mounted from the host into the rviz2 containers as /tmp/.X11-unix, the same way you would mount a desktop's socket. The paths and permission checks are the same as on a desktop, but this is not a real desktop. A real session has a window manager and other clients connected all the time, and that matters for xhost (see below). I also had no GPU, so every working run used Mesa's llvmpipe software renderer.

The images were osrf/ros:humble-desktop, osrf/ros:jazzy-desktop and osrf/ros:lyrical-desktop, run one distro at a time. The rviz2 and rqt containers used the plain image. For the X server, glxinfo and xvfb-run, I made a second image from the same base with xvfb xauth x11-utils x11-xserver-utils mesa-utils added. Each GUI run was timeout -k 5 30 rviz2, so exit code 124 means rviz2 was still running after 30 seconds. For every 124 I also checked from the X server side that the window existed. xwininfo listed "RViz" at 1200x846, and rviz2 had logged OpenGl version: 4.5 (GLSL 4.5).

Case rviz2 exit rqt exit
No DISPLAY 134 (abort) 1
DISPLAY=:99, socket not mounted 134 Not tested
DISPLAY=:0, socket for :99 mounted 134 Not tested
Socket mounted, server uses a cookie, client has none 134 Not tested
Cookie file with a hostname entry, client has another hostname 134 Not tested
Same file, client started with --hostname equal to the entry 124 (running) Not tested
Cookie file with a wildcard (ffff) entry 124 Not tested
xhost +local:, +si:localuser:root or xhost + on a plain Xvfb 134 1
Same xhost rules, Xvfb started with -noreset 124 still running at 30 s
Xvfb started without -auth, client has no cookie 124 Not tested
QT_QPA_PLATFORM=offscreen, no X server 134 still running at 30 s
xvfb-run -a rviz2 inside the container 124 Not tested
Mesa DRI removed, or libglx-mesa0 removed, or server without GLX 134 still running at 30 s

"Still running at 30 s" means rqt didn't exit on SIGTERM and was killed 5 seconds later (exit 137), with its window on the X server.

Cause 1: no display or no socket

Without DISPLAY, the message ends with a blank: could not connect to display . With DISPLAY=:99 but no socket mount, it names the display: could not connect to display :99. Setting DISPLAY=:0 while only the :99 socket was mounted gave could not connect to display :0. All three are the same failure. Qt looked for /tmp/.X11-unix/X<n> inside the container and found nothing it could connect to.

The "Reinstalling the application may fix this problem" line is generic Qt text. The xcb plugin was present in every image. QT_DEBUG_PLUGINS=1 listed it in /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms on Humble and Jazzy, and rviz2 loaded it as soon as a display was reachable. Inside the container, echo $DISPLAY should match the host, and ls /tmp/.X11-unix should show a socket with that number.

Cause 2: Authorization required

The first line, Authorization required, but no authorization protocol specified, comes from the X client library, not from Qt. It means the socket worked and the server said no. A desktop X server normally requires a cookie, the same as my Xvfb with -auth. A container started with only -e DISPLAY and -v /tmp/.X11-unix has no cookie, so it fails here.

Just copying a cookie isn't enough. A normal xauth entry is tied to a hostname. I created the entry inside the X server container (hostname rvz-x), and xauth list showed rvz-x/unix:99. Mounted into an rviz2 container with a random hostname, that file gave the same Authorization required error. The same file worked when I started the client with --hostname rvz-x. The robust fix is the sed -e 's/^..../ffff/' step from the short answer, which rewrites the entry's address family to "wild" so it matches any hostname. With that file, rviz2 started on all three distros with the default bridge network.

Why xhost +local: didn't work on Xvfb

Most answers say to run xhost +local: on the host. On my plain Xvfb, xhost +local:, xhost +si:localuser:root and even xhost + all printed success, and rviz2 still got Authorization required. The output shows why. The next connection after xhost + reported access control enabled, only authorized clients can connect. The X server resets when its last client disconnects, and the reset throws away the xhost change. xhost was the only client, so the rule was gone before rviz2 connected.

Started with -noreset, the same Xvfb kept the rule (LOCAL: in the list). Then xhost +local: and xhost +si:localuser:root each let rviz2 and rqt start without a cookie. After xhost -si:localuser:root, rviz2 failed again. On a desktop session the window manager stays connected, so the server doesn't reset and xhost +local: should stick. I didn't test that on a real desktop. If you script Xvfb yourself and use xhost, add -noreset. An Xvfb started without -auth accepted clients with no cookie at all.

Cause 3: OpenGL after the window opens

Once Qt connects, rviz2 creates an Ogre render window through GLX, and that is where the second group of errors comes from. The desktop images include Mesa. Through Xvfb, glxinfo -B reported llvmpipe with Accelerated: no and OpenGL 4.5 on all three. To get the errors from the forum threads, I removed parts of the GL stack inside the container before starting rviz2.

  • Mesa DRI drivers removed (dpkg --purge --force-depends libgl1-mesa-dri, plus mesa-libgallium on Jazzy and Lyrical). On Humble: libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file, Unable to create glx context, then Failed to create an OpenGL context. BadValue (integer parameter out of range for operation) and Unable to create a suitable GLXContext, 100 times each. On Jazzy and Lyrical there was no libGL error. They printed qt.glx: qglx_findConfig: Failed to finding matching FBConfig, Unable to create glx visual and 100 copies of Invalid parentWindowHandle (wrong server or screen).
  • libglx-mesa0 removed: Unable to create glx visual and Invalid parentWindowHandle on all three.
  • X server without GLX (Xvfb ... -extension GLX): the same Unable to create glx visual and Invalid parentWindowHandle on all three. The client had a full Mesa install, so the server side alone produced the error.

rqt started normally in all three cases. Plain Qt widgets don't need GLX, so "rqt works but rviz2 doesn't" points at GL, not at the display setup.

LIBGL_ALWAYS_SOFTWARE=1 changed nothing here

With Mesa present, LIBGL_ALWAYS_SOFTWARE=1 gave the same llvmpipe renderer and the same working rviz2. With Mesa removed, it gave exactly the same errors as without it. It tells Mesa to pick its software driver. It can't help when Mesa's drivers aren't installed, and it can't fix a server that has no GLX. Not tested: a GPU, or a host with NVIDIA's GLX, where forcing software rendering is the usual workaround.

If RViz opens but shows no topics from nodes on the host, that is a DDS problem, not an X problem. See topic echo prints nothing in Docker --net=host (Fast DDS shared memory) and ROS 2 nodes can't see each other (ROS_AUTOMATIC_DISCOVERY_RANGE).

Headless: offscreen fails, xvfb-run works

QT_QPA_PLATFORM=offscreen got Qt past the xcb error. rviz2 then printed Unable to open display: and aborted with terminate called after throwing an instance of 'Ogre::RenderingAPIException', what(): RenderingAPIException: Couldn`t open X display in GLXGLSupport::getGLDisplay, exit 134. Ogre's GL render system opens its own X connection, so a Qt-only offscreen mode doesn't help. rqt did run under offscreen. It printed This plugin does not support propagateSizeHints() and stayed up.

xvfb-run -a rviz2 inside the container worked on all three distros once the xvfb package was installed. It isn't in the desktop images. The xvfb-run script in all three images defaults to XVFBARGS="-screen 0 1280x1024x24", so I didn't need to pass -s. Passing -s '-screen 0 1280x1024x24' by hand made no difference. On Humble and Jazzy, stopping it printed X connection to :99 broken (explicit kill or server shutdown)., which only means the server went away.

Fix options compared

Option Result in my runs Trade-off
-e DISPLAY, socket mount, wildcard cookie file with XAUTHORITY Worked on all three Two extra lines on the host. Only containers that get the file can connect
Same, cookie file not converted to wildcard Failed unless the container hostname matched the entry Breaks silently when the hostname changes
xhost +local: or +si:localuser:root Worked only when the server didn't reset (-noreset in my test) +local: lets any local process use your display
xhost + Same reset problem. Not needed once a narrower rule works Turns off access control entirely
xvfb-run in the container Worked on all three No visible window. Needs xvfb installed. Fine for CI or screenshots
QT_QPA_PLATFORM=offscreen rviz2 aborted on all three Works for rqt only

I also checked the flags people add out of habit. With the socket mounted and a valid cookie, rviz2 started the same way with the default bridge network, --network none and --network host. It also started with and without sharing the X server's IPC namespace, and with and without QT_X11_NO_MITSHM=1. No MIT-SHM errors appeared in any run. One more result: with no socket mount at all, --network container:rvz-x (the X server's network namespace) also worked. Linux X clients can reach the server through an abstract socket, and that socket lives in the network namespace. That suggests --network host can reach a desktop's X server even without the /tmp/.X11-unix mount. I didn't test it against a real host X server, so mount the socket anyway. For ROS traffic between containers on --network host, see the other posts on huntlab.app.

Version notes

Humble and Jazzy rviz2 use Qt 5 (5.15.3 and 5.15.13). Lyrical's librviz_common links libQt6Core.so.6 (Qt 6.10.2). That's why only Lyrical adds the xcb-cursor0 hint to every display failure. Lyrical also logged Could not open file: /root/.rviz2/persistent_settings as an ERROR on every start, including the working ones, so you can ignore it. The OpenGL failures differed by Mesa version. Humble (Mesa 23.2.1) printed the libGL swrast error and Failed to create an OpenGL context. BadValue when the DRI drivers were missing. Jazzy (Mesa 25.2.8) and Lyrical (Mesa 26.0.8) printed Invalid parentWindowHandle for the same change. Ogre's source path in the messages is ogre-v1.12.1 on Humble and ogre_vendor on Jazzy and Lyrical, which matters if you search for the full line.

Not tested

A real X11 desktop, Wayland or XWayland, NVIDIA or any GPU passthrough (--gpus, --device /dev/dri), macOS with XQuartz, WSLg, rocker, VNC or noVNC images, rootless Docker, a non-root user inside the container, Foxy, Iron and Rolling. Every working run used llvmpipe software rendering, so I have no frame rate numbers.

FAQ

What does "qt.qpa.xcb: could not connect to display" mean in Docker?

Qt inside the container couldn't open an X connection. In my runs it meant one of three things: DISPLAY was unset (the message ends in a blank), /tmp/.X11-unix wasn't mounted, or DISPLAY named a display with no socket. Reinstalling Qt doesn't help, because the xcb plugin was present every time.

How do I fix "Authorization required, but no authorization protocol specified"?

Give the container a cookie it can use. Run xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f /tmp/.docker.xauth nmerge - on the host, mount that file, and set XAUTHORITY to it. An unconverted cookie failed whenever the container hostname differed from the entry.

Why doesn't xhost +local: fix it?

On my plain Xvfb the rule disappeared as soon as xhost disconnected, because the server reset when its last client left. The next connection saw access control enabled with no local rule. With Xvfb -noreset, xhost +local: worked. A desktop session normally keeps clients connected, so it doesn't reset like that.

Can I run rviz2 with QT_QPA_PLATFORM=offscreen?

Not in my runs. Qt started, then Ogre aborted with Couldn`t open X display in GLXGLSupport::getGLDisplay on Humble, Jazzy and Lyrical. xvfb-run -a rviz2 worked on all three after installing the xvfb package.

What causes "Failed to create an OpenGL context" or "Invalid parentWindowHandle" in rviz2?

No usable GLX. On Humble, missing Mesa DRI drivers gave Failed to create an OpenGL context. BadValue. On Jazzy and Lyrical the same change gave Invalid parentWindowHandle, as did a missing libglx-mesa0 or an X server without GLX on all three. LIBGL_ALWAYS_SOFTWARE=1 didn't change any of these.

Measured on 2026-10-30 with osrf/ros:humble-desktop (sha256:fb07245b3218..., rviz2 11.2.28, Qt 5.15.3, Mesa 23.2.1), osrf/ros:jazzy-desktop (sha256:2f520187e843..., rviz2 14.1.22, Qt 5.15.13, Mesa 25.2.8) and osrf/ros:lyrical-desktop (sha256:cd0f24da968e..., rviz2 15.2.5, Qt 6.10.2, Mesa 26.0.8), Docker on a headless x86_64 Linux server, with Xvfb 21.1 in a separate container as the X server. Full digests and package versions are in digests.txt.

Script and raw output: evidence folder. Questions this answers: qt.qpa.xcb: could not connect to display :1, ROS2: rviz in docker container, how to run ROS2 RIVZ in docker on macos, rviz2 error on ROS2 jazzy, RenderingAPIException causes rviz2 to crash after 100 tries.