LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Could not open display error (https://www.linuxquestions.org/questions/linux-general-1/could-not-open-display-error-120399/)

reyemarr 11-27-2003 05:23 AM

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

iainr 11-27-2003 08:51 AM

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.

fatgod 11-27-2003 09:01 AM

before you do your "su -" do "xhost +localhost" to allow any user on localhost to send x windows to yourself on localhost.

reyemarr 11-28-2003 05:58 AM

Hi guys,

I tried all your suggestions, but I still get the same error message. Any more ideas??

fatgod 11-29-2003 09:29 AM

Hmm, just try doing "xhost +" before doing the su and see if that works

iainr 11-29-2003 12:09 PM

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

reyemarr 11-30-2003 02:08 AM

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

iainr 11-30-2003 11:38 AM

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.

reyemarr 12-01-2003 03:05 AM

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

iainr 12-01-2003 03:56 AM

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.

JZL240I-U 12-02-2003 02:29 AM

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>
login
root
<root's password>
startx -- :2 &

Last line with blanks/spaces exactly as shown.

reyemarr 12-03-2003 03:30 AM

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!!!!!!!!!!!!!

JZL240I-U 12-03-2003 03:44 AM

Quote:

Originally posted by reyemarr
...
reyemarr@d4500:~$ su -
...

Again, long shot (but easy to try). Use
Code:

su
without the dash/minus (takes a different set of defaults for your shell). It might just perhaps ... ;)

PS: Did you have a look at your XF86conf (?) file to make sure there are no pecularities?

reyemarr 12-04-2003 07:14 AM

That was it !!!!!!! I still need to do "xhost +local:root" before I do su, but now it works. Thank you guys... ::-):

zorbital 12-06-2003 10:23 PM

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.