blackswords
Posts: 12
Joined: Sat Dec 22, 2012 12:47 pm

[SOLVED] "cannot connect to X server" after some time

Tue Mar 12, 2013 8:57 pm

Hello,

I'm using a Pi "headless" for a few months now and I still get the same annoying issue. The X11 server on the Pi is working great but after some time (minutes, hours, ...) I get this message when I try to start a graphical application : cannot connect to X server localhost:10.0.

The "solution" I found is to logout from the ssh session and log me in again. After that everything works fine.

Does someone now how to fix this issue?

My computers clients are 2 Mac (10.7 and 10.8), same issue with both
Last edited by blackswords on Thu Mar 14, 2013 12:28 am, edited 1 time in total.

thepiman
Posts: 42
Joined: Mon Nov 19, 2012 5:06 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 9:39 pm

I had the same error only all the time and this was my solution:

Issue: Unable to launch applications through SSH on my windows machine.

Solution:
1. Configure SSH on your pi. Use raspi-config to enable.
2. Download and install xming and putty for your windows machine.
3. Config your router to port forward all traffic to your internal IP (ie 192.168.1.5)
4. Note your external IP address. use whats my ip (google search) if you cant find it.
5. Open Putty and enter the external Ip into "Hostname (or IP)" section
-Connection = "SSH"
-Name the saved session and press save.
6. Now click Catagory SSH>X11. "Click enable X11 forwarding"
7. Open Xming after the install completes.
8. In putty click catagory "session" and click load.
9. Login into your rpi.
10. Type

Code: Select all
ssh -X <hostname> <application name>


10.1 Example to launch dillo with hostname rpi = ssh -X rpi dillo
11. Enter your password and whalla the application launches.

Note the command must be -X not -x. As for the command itself I am not sure if this is the best way but its the one that works for me.
ThePiMan - "Oh Yeah"

blackswords
Posts: 12
Joined: Sat Dec 22, 2012 12:47 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 9:51 pm

Thanks but as I said (maybe it was not well explained, sorry I'm French) X11 is working great. I can launch all the graphical applications I want but after some time I have the error message "cannot connect to X server localhost:10.0". I'm on OS X so everything is native, ssh and X11 (called XQuartz on 10.8 Mountain Lion).

thepiman
Posts: 42
Joined: Mon Nov 19, 2012 5:06 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 9:56 pm

Do not apologize your English is far better than any 2nd language I have.

Have you tried -Y for a trusted connection ?

also /etc/ssh/sshd_config might have timouts set ?
ThePiMan - "Oh Yeah"

blackswords
Posts: 12
Joined: Sat Dec 22, 2012 12:47 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 10:08 pm

I think I already tried ssh -Y without any success but I will try again just to be sure.

In /etc/ssh/sshd_config it didn't see any timeout. You can watch the entire content here if you want to check.

thepiman
Posts: 42
Joined: Mon Nov 19, 2012 5:06 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 10:15 pm

Could you be in the middle of using it when it happens or only when it is idle (not in use) that it disconnects ?

Also does this happen on a local network (both the mac and the raspberrypi on the same network) or via the internet ? or both?
ThePiMan - "Oh Yeah"

blackswords
Posts: 12
Joined: Sat Dec 22, 2012 12:47 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 10:29 pm

It can happen when I'm using QtCreator for example, I want to start an application after a build and I got the same error.

Both devices are on my home network but I never tried launching X applications from the outside, only standard ssh sessions.

thepiman
Posts: 42
Joined: Mon Nov 19, 2012 5:06 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 10:43 pm

I know this is not a solution to the issue but why not remote into the device with RDC ?
ThePiMan - "Oh Yeah"

blackswords
Posts: 12
Joined: Sat Dec 22, 2012 12:47 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 10:51 pm

you mean something like vnc? It actually what I'm doing when I got a lot of "deconnections", like now...
But I'm trying to avoid doing this because of some keyboard mapping problems (can't do some { } for example, quite annoying in programming)

thepiman
Posts: 42
Joined: Mon Nov 19, 2012 5:06 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 11:10 pm

Oh ya that would be terribly annoying. could you try setting up a port forwarding on the port used for ssh to see if that would help any ? Other than that it seems to be some sort of networking issue.

then try connecting via the external IP. It most likely wont fix it but its worth a shot.
ThePiMan - "Oh Yeah"

blackswords
Posts: 12
Joined: Sat Dec 22, 2012 12:47 pm

Re: "cannot connect to X server" after some time

Tue Mar 12, 2013 11:16 pm

yes, you can try to connect to navarro-benjamin.dyndns.org on port 2200 with pi/raspberry for the logging. You can use gedit or wpa_gui for the tests

EDIT : Well, I don't know if it's because of using ssh -Y but it doesn't seem to bug anymore. But usually it's when we say something like that that the problems happen...

thepiman
Posts: 42
Joined: Mon Nov 19, 2012 5:06 pm

Re: "cannot connect to X server" after some time

Wed Mar 13, 2013 10:46 pm

I am glad it is working for you.
ThePiMan - "Oh Yeah"

blackswords
Posts: 12
Joined: Sat Dec 22, 2012 12:47 pm

Re: "cannot connect to X server" after some time

Thu Mar 14, 2013 12:28 am

no issues today, I think the problem is solved.

Thanks for your help

Return to “Troubleshooting”

Who is online

Users browsing this forum: klricks and 46 guests