Solving /usr/lib/Xorg.wrap: Only console users are allowed to run the X server errors with tmux over SSH

On my Linux machines, I use BSPWM as my window manager, and instead of using a login greeter, I used to log into the TTY on startup and run:

startx

That got annoying, then I added the following to ~/.zlogin:

[[ -z "$DISPLAY" && $XDG_VTNR -eq 1 ]] && exec startx

This allowed me to log into TTY1 and auto-start Xorg, but any other TTY would give me a regular shell.

However, when I SSH onto the machine - usually from my laptop - and connect to a running tmux session, I've fairly often received the following error:

/usr/lib/Xorg.wrap: Only console users are allowed to run the X server

This stops me opening any new windows, and can be super frustrating.

Today, I finally solved it with:

-[[ -z "$DISPLAY" && $XDG_VTNR -eq 1 ]] && exec startx
+[[ -z "$DISPLAY" && $XDG_VTNR -eq 1 && -z "$SSH_CONNECTION" ]] && exec startx

Which makes sure that this only affects non-SSH shells, and now no longer triggers the error πŸ‘

Written by Jamie Tanna's profile image Jamie Tanna on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #linux #tmux #ssh.

This blog post is 100% human-written, and has nothing derived from LLMs (be it code, editorial support or prose).

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.