HTTP 500: Internal Server Error

Setup

Ubuntu18.04 on my jupyterhub-server
Ubuntu20.04 on my cluster node
python3.8
node v14.8.0
batchspawner 1.1.0
jupyterhub 1.3.0

I am trying to run my notebook on a remote node using batchspawner.SlurmSpawner
My job is properly started using slurm.
while executing cmd = batchspawner-singleuser jupyterhub-singleuser --ip=0.0.0.0 --debug
I run into:

batchspawner-singleuser jupyterhub-singleuser --ip=0.0.0.0 --debug
Error connecting to http://127.0.0.1:8081/hub/api: HTTPConnectionPool(host=‘127.0.0.1’, port=8081): Max retries exceeded with url: /hub/api/batchspawner (Caused by NewConnectionError(’<urllib3.connection.HTTPConnec
tion object at 0x7fc1fdf67190>: Failed to establish a new connection: [Errno 111] Connection refused’))
Traceback (most recent call last):
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/connection.py”, line 159, in _new_conn
conn = connection.create_connection(
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/util/connection.py”, line 84, in create_connection
raise err
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/util/connection.py”, line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 670, in urlopen
httplib_response = self._make_request(
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File “/apps/python/3.8-anaconda/lib/python3.8/http/client.py”, line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/apps/python/3.8-anaconda/lib/python3.8/http/client.py”, line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/apps/python/3.8-anaconda/lib/python3.8/http/client.py”, line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/apps/python/3.8-anaconda/lib/python3.8/http/client.py”, line 1010, in _send_output
self.send(msg)
File “/apps/python/3.8-anaconda/lib/python3.8/http/client.py”, line 950, in send
self.connect()
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/connection.py”, line 187, in connect
conn = self._new_conn()
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/connection.py”, line 171, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fc1fdf67190>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/requests/adapters.py”, line 439, in send
resp = conn.urlopen(
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 726, in urlopen
retries = retries.increment(
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/urllib3/util/retry.py”, line 446, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘127.0.0.1’, port=8081): Max retries exceeded with url: /hub/api/batchspawner (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7fc1fdf67190>: Failed to establish a new connection: [Errno 111] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/jupyterhub/services/auth.py”, line 332, in _api_request
r = requests.request(method, url, **kwargs)
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/requests/sessions.py”, line 530, in request
resp = self.send(prep, **send_kwargs)
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/requests/sessions.py”, line 643, in send
r = adapter.send(request, **kwargs)
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘127.0.0.1’, port=8081): Max retries exceeded with url: /hub/api/batchspawner (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7fc1fdf67190>: Failed to establish a new connection: [Errno 111] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “~/.local/bin/batchspawner-singleuser", line 6, in
main()
File “~/.local/lib/python3.8/site-packages/batchspawner/singleuser.py", line 16, in main
hub_auth._api_request(method=‘POST’,
File “/apps/python/3.8-anaconda/lib/python3.8/site-packages/jupyterhub/services/auth.py”, line 345, in _api_request
raise HTTPError(500, msg)
tornado.web.HTTPError: HTTP 500: Internal Server Error (Failed to connect to Hub API at ‘http://127.0.0.1:8081/hub/api’. Is the Hub accessible at this URL (from host: tf095)? Make sure to set c.JupyterHub.hub_ip to an IP accessible to single-user servers if the servers are not on the same host as the Hub.)

hub_ip is set in my jupyterhub_config.py

c.JupyterHub.hub_bind_url = 'http://jupyterhub:8081' # the ip was redacted and replaced by jupyterhub 
c.JupyterHub.hub_ip = 'jupyterhub' # the ip was redacted and replaced by jupyterhub 
c.JupyterHub.hub_connect_ip = 'jupyterhub'  # the ip was redacted and replaced by jupyterhub 

From the last error and the fact that I define hub_ip my assumption is that the configuration is not properly parsed from the JupyterHub server to my worker-node.

Any further information I should provide or checks I need to perform?

Indeed it does look like the hub ip config is not being passed to the spawner process. Perhaps you can get a hint by dumping the environment variables of the process? This should be in JUPYTERHUB_API_URL I believe.

Maybe SlurmSpawner has to do something special?

Thanks minrk,

#SBATCH --export=NONE
from my slurm header was overwriting this parameter

→ problem solved.