-   Linux - Newbie (
-   -   anybody familiar with this error "Xlib: connection to ":0.0" refused by server" ? (

rajnivanza 03-06-2008 04:55 AM

anybody familiar with this error "Xlib: connection to ":0.0" refused by server" ?
hi everybody,

i have problem regarding KDE environment.
i want to open gedit/kwrite application through program from one linux machine to another linux machine.
its work well when login user as "root" but when login user as "normal user" then display error.

I have written given below code:

cCommand = "gedit" / "kwrite"
uname = "/root" / "/home/rajni"

int executeCommand( char *cCommand )
char *uname = malloc (sizeof(char) * UNAME_MAX);
if(homeDir(uname) == FAILURE) {
free( uname );
setError( FNAME, "[Error] : homeDir() failed\n" );
return FAILURE;

pid_t pid=fork(); //don't know how vfork and environ works together.
setError(FNAME,"fork failed. executeCommand()\n");
return FAILURE;
else if(pid == 0) //child
setenv("HOME",uname,1); //proper solutions pending. see ~/.Xauthority, xauth etc.
free( uname );
exit(system(cCommand)); //beware of: return(system(cCommand));
else //parent
sleep(1); //let the child run first
int status;
if (waitpid (pid, &status, WNOHANG) == pid)
if (WIFEXITED (status) && WEXITSTATUS (status) == 32512) //system() returns this on
char msg[100];
sprintf(msg,"unable to execute %s. executeComamnd()\n",cCommand);
setError (FNAME,msg); //not working. debug it.
return FAILURE;
return SUCCESS;

we get right username path and display error as :
->Xlib: connection to ":0.0" refused by server
->Xlib: No protocol specified

and so,it can't execute the "gedit" / "kwrite" Xcommand successful.

Why is this happening, and how do I fix it?

I would be very grateful if I could receive your favorable reply.


acid_kewpie 03-06-2008 06:01 AM

yes plenty. if you'd searched this site you'd have seen well over 100 identical questions - some of which shown at the bottom of this very page...

run "xhost +" to let any user anywhere open programs on your local x server. or fine tune for better security.

Sm1ler 03-14-2008 07:12 AM

Why not try ssh -o ForwardX11=yes user@host Then simply run gedit & Works fine for me is simple and doesn't require any further config.

Elinornrond 03-22-2009 06:10 PM

X-forward using xauth on RHEL5 and Oracle Enterprise Linux 5
Or you can use a secure option through xauth.

(Oracle RHEL5u3)
Modify /etc/gdm/gdm.conf and set DisallowTCP=False (defaults to True) on the receiving server to allow display receipt over TCP.

Restart gdm

Add the X-server on which you wish to see your xclock, xterm or gedit to the .Xauthority-file on the target host:

xauth extract - <receiving host>:0 | ssh <target host> xauth merge -

The <receiving host> must be known to both hosts. If you have more than one subnet be careful which 'display' you add to the .Xauthority-file.

-- See also: man xauth --

All times are GMT -5. The time now is 07:18 PM.