{"id":4068,"library":"jupyter-kernel-gateway","title":"Jupyter Kernel Gateway","description":"Jupyter Kernel Gateway is a web server for spawning and communicating with Jupyter kernels. It provides a REST API that allows execution of code in Jupyter Kernels and manages their lifecycle, often used to expose notebooks as RESTful APIs. The current version is 3.0.1, and the project maintains an active release cadence with several updates per year, now managed under the `jupyter-server` organization.","status":"active","version":"3.0.1","language":"en","source_language":"en","source_url":"https://github.com/jupyter-server/kernel_gateway","tags":["jupyter","kernel","gateway","server","api","rest"],"install":[{"cmd":"pip install jupyter-kernel-gateway","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python 3.8 or newer.","package":"python","optional":false}],"imports":[],"quickstart":{"code":"import subprocess\nimport sys\nimport time\nimport requests\n\n# Start Kernel Gateway in a separate process\nprint(\"Starting Jupyter Kernel Gateway on port 9999...\")\nprocess = subprocess.Popen(\n    [sys.executable, \"-m\", \"jupyter_kernel_gateway.app\",\n     \"--KernelGatewayApp.port=9999\",\n     \"--KernelGatewayApp.ip=127.0.0.1\",\n     \"--KernelGatewayApp.allow_origin='*'\"],\n    stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True\n)\n\n# Give it a moment to start up\ntime.sleep(5)\n\ntry:\n    # Verify it's running by hitting an endpoint\n    print(\"Attempting to connect to Kernel Gateway...\")\n    response = requests.get(\"http://127.0.0.1:9999/api/kernelspecs\")\n    response.raise_for_status()\n    print(\"Kernel Gateway is running and accessible. Available kernelspecs:\")\n    print(response.json())\nexcept Exception as e:\n    print(f\"Error connecting to Kernel Gateway: {e}\")\n    if process.poll() is not None:\n        stdout, stderr = process.communicate()\n        print(\"Server stdout:\\n\", stdout)\n        print(\"Server stderr:\\n\", stderr)\nfinally:\n    print(\"Stopping Kernel Gateway...\")\n    if process.poll() is None: # Check if still running\n        process.terminate()\n        process.wait(timeout=5)\n    print(\"Kernel Gateway stopped.\")\n","lang":"python","description":"This quickstart demonstrates how to programmatically start the Jupyter Kernel Gateway server and make a simple API request to verify its operation. In typical use, Kernel Gateway is run directly from the command line using `jupyter kernelgateway`."},"warnings":[{"fix":"Review custom code and remove any dependencies on `ipython_genutils` modules. Migrate to equivalent functionality in `traitlets` or standard Python libraries.","message":"Starting from v2.5.2, `jupyter-kernel-gateway` removed its internal dependency on `ipython_genutils`. Custom extensions or deployment scripts that relied on this module might break upon upgrade.","severity":"breaking","affected_versions":">=2.5.2"},{"fix":"Upgrade `jupyter-kernel-gateway` to version 3.0.0 or later, which has updated dependency requirements. Alternatively, ensure your `jupyter-client` version is compatible (e.g., `<8`) when using older `jupyter-kernel-gateway` versions.","message":"Versions of `jupyter-kernel-gateway` prior to 3.0.0 were pinned to `jupyter-client < 8`. Users with a newer `jupyter-client` version in their environment might encounter dependency conflicts or unexpected behavior.","severity":"gotcha","affected_versions":"<3.0.0"},{"fix":"Always review and configure `KernelGatewayApp` settings, especially `ip`, `port`, `allow_origin`, and `auth_token` or other authentication mechanisms suitable for your deployment scenario. Consult the official documentation for comprehensive security guidelines.","message":"When deploying `jupyter-kernel-gateway` as a public-facing service, critical security configuration like CORS origins (`--KernelGatewayApp.allow_origin`) and authentication must be explicitly set. Default settings are not secure for production environments.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}