cannot connect to x server error
Solution 1
This answer is a cannon to kill a rabbit, but if all you're interested in sudo
ing X applications that is what you'll need.
The solution:
Add to your ~/.bashrc
# Fabby: 2014-11-14: http://askubuntu.com/questions/571116/
# to allow forwarding of xauth keys between users when calling su
# needs to be the last line
export $(dbus-launch)
The explanation:
- Do you know what the X server is? OK!
- Do you know that it has a client/server technology? OK!
- Do you know what D-Bus is? OK!
- Well, now the dbus-launch variable gets exported so that x messages from one user session can use other user's session! Plain and simple!
Solution 2
I am using SecureCRT as ssh tool, however it cannot display some plots on local host with Windows OS. I have the same problem when using Canopy.
Solutions:
- Install Xmanager, running Xmanager Passive.
- Add "export DISPLAY=your ip:0.0" in ~/.bashrc, source ~/.bashrc (ip is your host IP, where you wanna display plots or things like that. If you are using Windows, cmd-ipconfig, find your IP).
- Test (i.e. $xclock, you can see a clock in your windows screen) or directly test your own GUI applications.
Done!
Related videos on Youtube
Logan Young
Day Time: C++, C... Night Time: PCL, Robots, ROS, Motion Planning, etc...
Updated on September 18, 2022Comments
-
Logan Young over 1 year
I have a camera application which I am trying to run under sudo: but I am receiving this error
cannot connect to x server
the issue is when I dont use sudo, the program opens fine. However, there are certain parts of this application which still need admin privileges.
Since it is a GUI application, I tried to use gksudo then it opens a window asking about the password, but after entering the password the application returns and GUI does not open!
I have tried also
sudo xhost local:root
and got:
xhost: unable to open display""
I am using lubuntu 14.04
-
Fabby over 9 yearsWhat application?
-
Logan Young over 9 years@Fabby, It is the camera manager application from IDS imaging company. It uses QT4 to build a gui application to perform Ethernet configuration.
-