Jupyter Notebook stores persistent server settings in a user configuration directory, so generating the base file is the first step before changing ports, authentication, browser launch behavior, working directory, or HTTPS settings. Notebook 7 runs on Jupyter Server behind the Notebook interface, so server settings belong in jupyter_server_config.py.
The jupyter server command creates the config file in the active Jupyter config directory, usually ~/.jupyter for a user account. The generated file is a Python config file with commented c.ServerApp settings that can be uncommented later when a specific setting needs to persist.
Generating the file does not change how Notebook starts until a setting is uncommented or added. If jupyter_server_config.py already exists, Jupyter prompts before overwriting it, so keep a backup before replacing a file that already contains custom settings.
Steps to generate a Jupyter Notebook configuration file:
- Show the active Jupyter configuration directory.
$ jupyter --config-dir /home/user/.jupyter
- Generate the Jupyter Server configuration file.
$ jupyter server --generate-config Writing default config to: '/home/user/.jupyter/jupyter_server_config.py'
If the file already exists, choose overwrite only after saving any custom settings that should remain.
- Confirm the generated file contains port settings for later edits.
$ grep -n "c.ServerApp.port" ~/.jupyter/jupyter_server_config.py 491:# c.ServerApp.port = 0 496:# c.ServerApp.port_retries = 50
ServerApp is the Jupyter Server configuration class used by Notebook 7. Leave generated lines commented until a setting needs to be enabled.
- Check another generated server setting from the same file.
$ grep -n "c.ServerApp.root_dir" ~/.jupyter/jupyter_server_config.py 523:# c.ServerApp.root_dir = ''
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.