"Error: GDK_BACKEND does not match available displays"

“Error: GDK_BACKEND does not match available displays”
This error pops up every time I try to open Firefox in the terminal, but for some reason I can still open it via the GUI. I only did two things prior to getting this error:

  1. I changed one value in the Firefox configuaration via the GUI (browser.privatebrowsing.autostart) from false to true (I’m guessing it was this one, but I’m not sure why this would matter).
  2. I installed a different browser (Brave browser) via the terminal. Text below:
sudo pacman -S snapd
sudo systemctl enable --now snapd.socket
snap install brave --beta

Anyone know how I can fix this?

I think you are missing part of the post…what error are you getting?

“Error: GDK_BACKEND does not match available displays”
It’s in the title, but I just added it to the main text.

Sorry I should have noticed that.

When you say terminal are you talking Alt-Ctrl-F2 terminal or a terminal emulator running in the GUI?

If I run firefox in an Alt-Ctrl-F2 terminal I get the same error, because there is no GUI for firefox to run in.

If you are running firefox under a terminal emulator running in the GUI, can you please provide the output from:

echo $DISPLAY

You can also try running:

DISPLAY=:0.0 firefox

Does that work correctly?

I’m talking about the terminal emulator in the GUI.

Side note, I just noticed that I’m currently using the emulator as “su -”, and it looks like I can get Firefox to work just fine by not doing that. Is launching Firefox from the emulator as “su -” not possible?

When using as a regular user, Display gives a normal output of 0.0, and gives no output at all as “su -”

When running

DISPLAY=:0.0 firefox

as “su -”, I get the following output

No protocol specified
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0.0

So, sorry if this is a dumb question, but what the hell just happened?

Basically when running with “su” environment variables are not passed over to the running process (I think it’s a security risk). That means the DISPLAY property is not passed over and firefox doesn’t know how to connect to the GUI.

As for setting DISPLAY in the su’ed environment not working…that is security again, X is disallowing the connection to “your” display from a root process. Normally I’d get around this by using xhost +localhost (it does look like you have to install xhost since it’s not installed by default at least on xfce).

Googling around and testing this works (without any additional installs):

sudo rm /root/.Xauthority
sudo touch /root/.Xauthority
su - -c "unset XAUTHORITY; xauth add $(xauth list)"

Which passes the secret cookie (result of “xauth list”) to the root user, so that when it tries to access the display it has the correct code. Just remember that you are now running firefox as root, which is usually frowned upon.

You can also add:

export DISPLAY=:0.0

to the script so that the DISPLAY environment variable is set correctly, then you should be able to just launch firefox like normal.

This was actually a really great explanation. Thank you!

Is there any reason why you are running Firefox as root btw?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by