[JupyterHub] cannot connect to X server

2,812 views
Skip to first unread message

Sachin Mehta

unread,
Aug 19, 2016, 8:02:56 PM8/19/16
to Project Jupyter

Whenever I create an empty notebook in JupyterHub, I get the following error (irrespective of the python version):

: cannot connect to X server

I logged into the server with ssh + X11 forwarding.
P.S.: I am starting the jupyterhub with --no-ssl command

Thomas Kluyver

unread,
Aug 20, 2016, 11:45:58 AM8/20/16
to Project Jupyter
Is it possible that something when a kernel starts is loading matplotlib (or pylab)? IPython itself shouldn't need an X server, but some matplotlib backends might.

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/0ea03f7c-0e07-4ad8-852e-281913fcc9c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sachin Mehta

unread,
Aug 22, 2016, 2:08:29 PM8/22/16
to Project Jupyter
Many thanks for your answer.

I do agree that matplotlib or pylab might be causing this issue. However, in jupyter notebook, we can control the invoking of these libraries using "c.NotebookApp.pylab = 'disabled' " command in jupyter_notebook_config.py file. Such an option doesn't exist in jupyterhub_config.py file. How can we disable pylab or matplotlib at the initialization of jupyterhub?

On Saturday, August 20, 2016 at 8:45:58 AM UTC-7, takowl wrote:
Is it possible that something when a kernel starts is loading matplotlib (or pylab)? IPython itself shouldn't need an X server, but some matplotlib backends might.
On 20 August 2016 at 01:02, Sachin Mehta <sachinm...@gmail.com> wrote:

Whenever I create an empty notebook in JupyterHub, I get the following error (irrespective of the python version):

: cannot connect to X server

I logged into the server with ssh + X11 forwarding.
P.S.: I am starting the jupyterhub with --no-ssl command

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

Thomas Kluyver

unread,
Aug 22, 2016, 2:46:38 PM8/22/16
to Project Jupyter
On 22 August 2016 at 19:08, Sachin Mehta <sachinm...@gmail.com> wrote:
I do agree that matplotlib or pylab might be causing this issue. However, in jupyter notebook, we can control the invoking of these libraries using "c.NotebookApp.pylab = 'disabled' " command in jupyter_notebook_config.py file. Such an option doesn't exist in jupyterhub_config.py file. How can we disable pylab or matplotlib at the initialization of jupyterhub?

It would be part of IPython's configuration, not Jupyter's (as it's specific to Python kernels), so it would be in ~/.ipython/profile_default/ . But IPython doesn't enable it by default, so unless you've set something in config already, that shouldn't be the issue. Is it possible that you have $PYTHONSTARTUP set?

Sachin Mehta

unread,
Aug 22, 2016, 5:34:56 PM8/22/16
to Project Jupyter
I checked the IPython configuration and I am not setting anything in IPython's configuration. I believe Jupyter and JupyterHub uses Ipython configuration file. I am able to run Jupyter notebook without any trouble but getting these errors with JupyterHub.

I checked the $PYTHONSTARTUP variable and it is empty.

Sachin Mehta

unread,
Aug 22, 2016, 6:24:17 PM8/22/16
to Project Jupyter
We found the issue.

When we are running Jupyter notebook, DISPLAY variable was set, but when we running JupyterHub DISPLAY variable was empty and thus we were getting this error.

We checked the Display variable as:

import os
print os.environ['DISPLAY']

Many thanks for your responses and help. Really appreciate that.

Thomas Kluyver

unread,
Aug 23, 2016, 3:34:30 AM8/23/16
to Project Jupyter
I'm still not sure why it needs DISPLAY at all; the IPython kernel should run in a headless environment. But I'm glad you worked it out.

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages