Skip to content

Instantly share code, notes, and snippets.

Created April 26, 2020 15:41
What would you like to do?
gtk: "No protocol specified" error on Linux as root user

GTK protocol error


If you are running as a root user while opening a GTK session on Linux i.e. using sudo, su, etc, you might encounter errors like:

No protocol specified
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/ GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
No protocol specified
Unable to initialize gtk: could not open display, falling back to console.

Why it occurs

This occurs generally due to Wayland. The root user does not have permissions to run programs in the current session.


Run xhost + local: to allow other users (including root) to run programs in the current session.

Try running your program again now, it should work! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment