LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-27-2003, 05:23 AM   #1
reyemarr
Member
 
Registered: Nov 2003
Location: Darwin, Australia
Distribution: Debian,Mandrake
Posts: 33

Rep: Reputation: 15
Angry 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
 
Old 11-27-2003, 08:51 AM   #2
iainr
Member
 
Registered: Nov 2002
Location: England
Distribution: Ubuntu 9.04
Posts: 631

Rep: Reputation: 30
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.
 
Old 11-27-2003, 09:01 AM   #3
fatgod
Member
 
Registered: Mar 2002
Location: Edinburgh, Scotland
Distribution: Suse 7.2, Gentoo 1.4, Solaris 9
Posts: 661

Rep: Reputation: 30
before you do your "su -" do "xhost +localhost" to allow any user on localhost to send x windows to yourself on localhost.
 
Old 11-28-2003, 05:58 AM   #4
reyemarr
Member
 
Registered: Nov 2003
Location: Darwin, Australia
Distribution: Debian,Mandrake
Posts: 33

Original Poster
Rep: Reputation: 15
Hi guys,

I tried all your suggestions, but I still get the same error message. Any more ideas??
 
Old 11-29-2003, 09:29 AM   #5
fatgod
Member
 
Registered: Mar 2002
Location: Edinburgh, Scotland
Distribution: Suse 7.2, Gentoo 1.4, Solaris 9
Posts: 661

Rep: Reputation: 30
Hmm, just try doing "xhost +" before doing the su and see if that works
 
Old 11-29-2003, 12:09 PM   #6
iainr
Member
 
Registered: Nov 2002
Location: England
Distribution: Ubuntu 9.04
Posts: 631

Rep: Reputation: 30
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
 
Old 11-30-2003, 02:08 AM   #7
reyemarr
Member
 
Registered: Nov 2003
Location: Darwin, Australia
Distribution: Debian,Mandrake
Posts: 33

Original Poster
Rep: Reputation: 15
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
 
Old 11-30-2003, 11:38 AM   #8
iainr
Member
 
Registered: Nov 2002
Location: England
Distribution: Ubuntu 9.04
Posts: 631

Rep: Reputation: 30
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.
 
Old 12-01-2003, 03:05 AM   #9
reyemarr
Member
 
Registered: Nov 2003
Location: Darwin, Australia
Distribution: Debian,Mandrake
Posts: 33

Original Poster
Rep: Reputation: 15
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
 
Old 12-01-2003, 03:56 AM   #10
iainr
Member
 
Registered: Nov 2002
Location: England
Distribution: Ubuntu 9.04
Posts: 631

Rep: Reputation: 30
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.
 
Old 12-02-2003, 02:29 AM   #11
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
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.

Last edited by JZL240I-U; 12-02-2003 at 02:30 AM.
 
Old 12-03-2003, 03:30 AM   #12
reyemarr
Member
 
Registered: Nov 2003
Location: Darwin, Australia
Distribution: Debian,Mandrake
Posts: 33

Original Poster
Rep: Reputation: 15
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!!!!!!!!!!!!!

Last edited by reyemarr; 12-03-2003 at 03:32 AM.
 
Old 12-03-2003, 03:44 AM   #13
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
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?

Last edited by JZL240I-U; 12-03-2003 at 03:46 AM.
 
Old 12-04-2003, 07:14 AM   #14
reyemarr
Member
 
Registered: Nov 2003
Location: Darwin, Australia
Distribution: Debian,Mandrake
Posts: 33

Original Poster
Rep: Reputation: 15
That was it !!!!!!! I still need to do "xhost +local:root" before I do su, but now it works. Thank you guys... ::-):
 
Old 12-06-2003, 10:23 PM   #15
zorbital
LQ Newbie
 
Registered: Oct 2002
Location: College Place, WA
Distribution: SuSE 8.1, Redhat 7.3, Lycoris b75
Posts: 8

Rep: Reputation: 0
Another suggestion

Try using the command sux instead of su

This automatically gives the X creditials to the superuser you become.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Can't open display (X-windows & apache) hsingams Linux - General 5 08-08-2005 08:34 PM
"Can't open display" error when try to use a program remote heande Linux - Newbie 2 03-11-2005 10:13 AM
Error: can't open display gopalkasat Linux - Networking 8 12-13-2004 01:59 PM
Suse 9.1 Error: Can't open display dan7 General 5 07-23-2004 10:59 AM
wdb Error: Can't open display: 172.16.1.28:0 murugesan Linux - Networking 4 02-19-2004 04:01 AM


All times are GMT -5. The time now is 03:52 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration