Could not open display error
When I try to run programs from a shell (konsole), I get errot message:
Xlib: connection to ":0.0" refused by server Xlib: No protocol specified synaptic:could not open display This only happens when I log in into X as user "xx", then do a "su -" to run a program only executable by root user (for instance, synaptic in debian). How do I go around this problem?? Thanks |
A couple of workarounds :
1. Use sudo. Instead of doing as su to root, set up sudo for your user and run the app. with sudo. 2. Alternatively, when logged on as root, set the DISPLAY variable to point to your screen (export DISPLAY=localhost:0.0 should do the trick). You may also need to allow "remote" connections to your screen so as your own user, type xhost + in a different session. |
before you do your "su -" do "xhost +localhost" to allow any user on localhost to send x windows to yourself on localhost.
|
Hi guys,
I tried all your suggestions, but I still get the same error message. Any more ideas?? |
Hmm, just try doing "xhost +" before doing the su and see if that works
|
A bit of debugging.
Before doing the su to root, enter the command "xhost" on its own. Post the output here. After you su to root, and type in the export DISPLAY command, enter the command "echo $DISPLAY" and post that output here. The thing that's confusing me is that you could explicitely set the DISPLAY variable to be "localhost:0.0" and yet the error still comes up that you are connecting to :0.0, not to localhost:0.0 |
Hi guys
Thanks for the responses. Iainr, here is what you requested: reyemarr@d4500:~$ xhost + access control disabled, clients can connect from any host reyemarr@d4500:~$ xhost access control disabled, clients can connect from any host reyemarr@d4500:~$ su - Password: d4500:~# export DISPLAY=localhost:0.0 d4500:~# echo $DISPLAY localhost:0.0 d4500:~# konqueror konqueror: cannot connect to X server localhost:0.0 d4500:~# ANy help is greatly appreciated. This problem, although small, is driving me crazy Again, thanks |
Can you check in your /etc/hosts file that localhost as IP address 127.0.0.1 (you could just try pinging localhost). If not, add it to /etc/hosts and try again.
|
Ianinr,
I checked and here are the results: d4500:/home/reyemarr# more /etc/hosts 127.0.0.1 d4500 localhost # The following lines are desirable for IPv6 capable hosts # (added automatically by netbase upgrade) ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts d4500:/home/reyemarr# ping localhost PING d4500 (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.0 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.0 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.0 ms --- d4500 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.0/0.0/0.0 ms As you can see, everything seems ok, yet I can't get it to work. !!!! Thanks |
OK, I'm pretty much out of ideas right now. It does all look like it should work.
You could try setting the DISPLAY variable to the IP address of your PC (not 127.0.0.1 but the external IP address). I doubt it will make any difference but there could be something wierd in the config. I guess you could try setting it to 127.0.0.1 as well, just to check (i.e. DISPLAY=127.0.0.1:0.0) The only other thing I can think of right now that that the X display is being blocked by a firewall or something like that. Try monitoring /var/log/messages (or any other likely looking log file) as you try to launch the app. |
Maybe this is a misunderstanding on my part, if so, please ignore. In your first post you [reyemarr] wrote: "When I try to run programs from a shell (konsole) ..."
Well, to me it is not exactly clear, whether X is up and running at all?!? Did you check? If everything is okay, does a second instance of your GUI work? To test type Code:
<Alt><Ctrl><F2> |
JZL240I-U,
Yes I am already running X, The problem is I can't run any graphical applications from the command line when I su to superuser. If I try, for instance, kate from the command line, I just get the "cant open dislay, connection refused error". On the other hand, if I do the same thing from a shell, while logged as a normal user (having started X as that same user), it works fine. Let me add that I tried doing the opposite; namely I started X as root, then switched user to a normal user, and tried loading kate (just an example), and it works fine. Any more ideas anybody. I'm going crazy!!!!!!!!!!!!! |
Quote:
Code:
su PS: Did you have a look at your XF86conf (?) file to make sure there are no pecularities? |
That was it !!!!!!! I still need to do "xhost +local:root" before I do su, but now it works. Thank you guys... ::-):
|
Another suggestion
Try using the command sux instead of su
This automatically gives the X creditials to the superuser you become. |
All times are GMT -5. The time now is 05:20 PM. |