Skip to main content Link Menu Expand (external link) Document Search Copy Copied


Moonraker is a web server that exposes APIs which lets Mainsail interact with Klipper.


At first we have to install some OS dependencies:

sudo apt install python3-virtualenv python3-dev libopenjp2-7 python3-libgpiod curl libcurl4-openssl-dev libssl-dev liblmdb-dev libsodium-dev zlib1g-dev libjpeg-dev

Clone Moonraker into your HOME directory:

cd ~
git clone

Then we can initialize the python virtual environment and install the python dependencies:

cd ~
virtualenv -p python3 ./moonraker-env
./moonraker-env/bin/pip install -r ./moonraker/scripts/moonraker-requirements.txt


Please pay attention to the following steps!
A very common source of errors are improperly configured trusted_clients.

For Moonraker you’ll need to create a separate config file.

nano ~/klipper_config/moonraker.conf

Insert the following part:

port: 7125
enable_debug_logging: False
config_path: ~/klipper_config
log_path: ~/klipper_logs


# enables partial support of Octoprint API

# enables moonraker to track and store print history.

# this enables moonraker's update manager

[update_manager mainsail]
type: web
repo: mainsail-crew/mainsail
path: ~/mainsail

This is a very basic config
For more options and detailed explanations you should follow Moonraker’s instructions.

🔥 trusted_clients - read carefully 🔥
A list of newline separated IP addresses and/or IP ranges that are trusted. Trusted clients are given full access to the API. Both IPv4 and IPv6 addresses and ranges are supported. Ranges must be expressed in CIDR notation (see CIDR for more info).
For example, an entry of will authorize IP addresses in the range of - Note that when specifying IPv4 ranges the last segment of the IP address must be 0. The default is no clients or ranges are trusted.

Save the file with CTRL+O and close the editor with CTRL+X.

Startup service

To edit this file type:

sudo nano /etc/systemd/system/moonraker.service

fill in these lines:

#Systemd moonraker Service

Description=Moonraker provides Web API for klipper
Documentation= klipper.service


ExecStart=/home/pi/moonraker-env/bin/python /home/pi/moonraker/moonraker/ -c ${MOONRAKER_CONFIG} -l ${MOONRAKER_LOG}

Save the file with CTRL+O and close the editor with CTRL+X.

Please check and modify the username!
If you do not use the user pi, you must replace it in each path and in the variable user in the service file.

To enable Moonraker service execute these commands:

sudo systemctl enable moonraker.service

After your config is in place, start Moonraker with sudo systemctl start moonraker.

Open the following URL with your printers IP in your browser


If everything has been set up successfully, a message like this should appear:

{"result": {"state_message": "Printer is ready", "klipper_path": "/home/pi/klipper", "config_file": "/home/pi/klipper_config/printer.cfg", "software_version": "v0.9.1-785-g1be19177", "hostname": "raspberrypi", "cpu_info": "4 core ARMv7 Processor rev 4 (v7l)", "state": "ready", "python_path": "/home/pi/klippy-env/bin/python", "log_file": "/home/pi/klipper_log/klippy.log"}}

< previous step next step >