Summary of JupyterHub Redirect Loop Issue (Docker Compose Setup)

Hello,

I’m seeking assistance with a persistent redirect loop in my Docker Compose deployment of JupyterHub. The error message is always the same:

500 : Internal Server Error Redirect loop detected. Notebook has jupyterhub version unknown (likely < 0.8), but the Hub expects 4.1.5. Try installing jupyterhub==4.1.5 in the user environment if you continue to have problems.

My setup details are:

  • JupyterHub Version: 4.1.6 (confirmed installed in both the hub and single-user containers).

  • Deployment: Docker Compose on an Ubuntu server.

  • Single-User Image: Based on Quay .

Here is a summary of the extensive troubleshooting I’ve already done:

  1. I have confirmed that the jupyterhub==4.1.6 package is correctly installed within the single-user container. The problem is not a missing package; it is a communication failure.

  2. The Dockerfile.jupyterhub has been configured to be self-contained and is no longer reliant on the base image’s default commands. It now explicitly sets the startup command with CMD ["start-singleuser.sh"].

  3. My docker-compose.yml file has been checked and corrected. It no longer contains a command: override for the singleuser service.

  4. My jupyterhub_config.py has been audited to ensure there are no conflicting c.DockerSpawner settings that could be overriding the startup command.

Despite all these changes and a complete rebuild, the error persists. Any help or ideas on what else could be causing this communication failure would be greatly appreciated.

Have you tried it with just the base image and no custom dockerfile? What do the logs say?

"Thanks for the suggestion!

I tried it with just the base image ( Quay ) and no custom Dockerfile.

The redirect loop is now gone, which is great. However, I am now getting a new error when trying to start the server:

500 : Internal Server Error Unhandled error starting server vskatusa

Here are the logs for the jupyterhub container, which should show the full error traceback:"

Looks like your network config is incorrect:

jupyterhub | [E 2025-08-14 05:40:45.376 JupyterHub user:887] Unhandled error starting vskatusa’s server: 404 Client Error for http+docker://localhost/v1.51/containers/08b5635c85373199eb3aac5519eb05e34f63c4555d806deb4bef4b4d51da0cbf/start: Not Found (“failed to set up container networking: network 8668e1e2bdeadac77461ad08f5c5ae3523cbd4f79a26a5264e2c8bcf2e48726d not found”)

There’s an example Docker deployment in

Subject: Still getting network not found error after all previous fixes

Hello, and thanks again for all your help.

I’m still getting the 500: Internal Server Error with the specific message “failed to set up container networking: network docadmin_docadmin_network not found”.

We’ve been troubleshooting this for a while, and based on the last analysis, I performed the following steps:

  1. I ran a full cleanup: docker rm -f jupyter-vskatusa, docker compose down --volumes, and docker system prune -f.

  2. I updated my jupyterhub_config.py file to set the network name to docadmin_docadmin_docadmin_network, which was the name identified by docker network ls.

  3. I restarted the services with docker compose up -d.

Despite these steps, the error persists. It appears the network is still not being found, even with the explicit and corrected name in the configuration.

Could you please help me understand what might be causing this persistent network error?

I’ve attached the most recent logs and my full configuration files for review. Thank you for your continued patience and assistance. docker compose logs jupyterhub - Pastebin.com

docadmin@docserver:~$ docker network ls

NETWORK ID NAME DRIVER SCOPE

caf3cc8c3df5 bridge bridge local

0eef94bdb68e docadmin_docadmin_docadmin_network bridge local

a17b4755edff host host local

6dce0fef03d6 none null local

docadmin@docserver:~$

jupyterhub_config.py - Pastebin.com (jupyterhub_config.py)

docker-compose.yml

  1. version: ‘3.8’

  2. services:

  3. # The main JupyterHub service, which manages user sessions and the proxy.

  4. jupyterhub:

  5. \# We will build our custom image from the Dockerfile in the current directory. 
    
  6. build: . 
    
  7. container_name: jupyterhub 
    
  8. restart: unless-stopped 
    
  9. volumes: 
    
  10.   \# This is the critical fix: mount the host's Docker socket 
    
  11.   - /var/run/docker.sock:/var/run/docker.sock 
    
  12.   \# Volume for persistent hub data and configuration 
    
  13.   - jupyterhub_data:/srv/jupyterhub 
    
  14.   \# Mount the config file 
    
  15.   - ./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py 
    
  16. environment: 
    
  17.   - JUPYTERHUB_CRYPT_KEY=${JUPYTERHUB_CRYPT_KEY} 
    
  18.   - GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID} 
    
  19.   - GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET} 
    
  20.   - OAUTH_CALLBACK_URL=${OAUTH_CALLBACK_URL} 
    
  21. command: jupyterhub -f /srv/jupyterhub/jupyterhub_config.py 
    
  22. networks: 
    
  23.   - docadmin_docadmin_network 
    
  24. depends_on: 
    
  25.   - mariadb 
    
  26. # The single-user notebook service, which will be spawned by JupyterHub for each user.

  27. singleuser:

  28. image: quay.io/jupyter/base-notebook:2024-03-14 
    
  29. \# build: 
    
  30. \#   context: . 
    
  31. \#   dockerfile: Dockerfile.jupyterhub 
    
  32. restart: unless-stopped 
    
  33. networks: 
    
  34.   - docadmin_docadmin_network 
    
  35. nginx:

  36. image: nginx:latest 
    
  37. container_name: nginx 
    
  38. restart: unless-stopped 
    
  39. ports: 
    
  40.   - "80:80" 
    
  41. volumes: 
    
  42.   - ./nginx-conf:/etc/nginx/conf.d 
    
  43. depends_on: 
    
  44.   - jupyterhub 
    
  45.   - flask-app  
    
  46. networks: 
    
  47.   - docadmin_docadmin_network 
    
  48. flask-app:

  49. build: ./flask-app 
    
  50. container_name: flask-app 
    
  51. working_dir: /app 
    
  52. networks: 
    
  53.   - docadmin_docadmin_network 
    
  54. restart: always 
    
  55. volumes:

  56. jupyterhub_data:

  57. networks:

  58. docadmin_docadmin_network:

  59. driver: bridge
    

You’ve used docadmin_docadmin_network in your docker compose file, but docadmin_docadmin_docadmin_network in your jupyterhub_config.py

Your jupyterhub should spawn the notebook. You don’t spawn the notebook from docker-compose. Remove the notebook part.

In your hub environment section add:
- DOCKER_NETWORK_NAME=<your network name here>

I don’t know how you why you want so many docadmins prepended to your network name.