Jupyter Server

2.17.0 · active · verified Sun Mar 29

Jupyter Server provides the backend services, APIs, and REST endpoints for Jupyter web applications like Jupyter Notebook, JupyterLab, and Voila. It is a replacement for the Tornado Web Server in older Jupyter Notebook installations. Currently at version 2.17.0, it maintains an active release cadence with frequent minor updates and bug fixes.

Warnings

Install

Imports

Quickstart

The most common way to start Jupyter Server is via the command line with `jupyter server`. For programmatic control, the `ServerApp` can be initialized and started within a Python script. This example demonstrates a minimal programmatic startup, explicitly disabling browser opening and authentication for demonstration purposes. **For production use, it is critical to enable and properly configure authentication (tokens/passwords).**

import asyncio
import os
from jupyter_server.serverapp import ServerApp

async def start_jupyter_server():
    # Instantiate the server application
    # For a quickstart, we disable browser opening and token/password for simplicity.
    # In production, ALWAYS secure your Jupyter Server with tokens/passwords.
    app = ServerApp(
        open_browser=False,
        port=os.environ.get("JUPYTER_SERVER_PORT", 8888),
        port_retries=0,
        token="", # IMPORTANT: Do NOT use empty token in production.
        password="" # IMPORTANT: Do NOT use empty password in production.
    )
    
    await app.initialize()
    await app.start()

    print(f"Jupyter Server running at: {app.url} (Access via web browser if not using --no-browser, use the printed URL including token if applicable)")
    print("Press Ctrl+C to stop the server.")

    try:
        # Keep the server running until interrupted
        await asyncio.Event().wait()
    except KeyboardInterrupt:
        print("\nServer stopping...")
    finally:
        await app.stop()

if __name__ == "__main__":
    # To run this, save as a Python file (e.g., `run_server.py`) and execute `python run_server.py`.
    # Alternatively, for a basic command-line start, simply run `jupyter server` in your terminal.
    asyncio.run(start_jupyter_server())

view raw JSON →