Help me please (running octoprint as root)

What is the problem?
You should not run octoprint as root
What did you already try to solve it?

Logs (octoprint.log, serial.log or output on terminal tab, browser error console ...)

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ...)

You'll need to provide more information if you hope to have some help. What is this installed on? What instructions did you follow?

And why do you think you need to run OctoPrint as root?

1 Like

I'm trying to do the same thing (Octoprint as root) because I'm using an string of RGB leds (WS2811) and trying to use the PWM on gpio 18. The test python script runs fine as 'sudo'. But I get a -5 error on mmap() call in the script.

Is there another pin to use for RGB_Status plug in?
Or a different pluging?

You don't need to run as root, instead you need to add the user running OctoPrint (usually pi) to the gpio group:

sudo adduser pi gpio

Hope that helps :slight_smile:

1 Like

And then again, OctoPrint itself (as delivered via the OctoPi image) uses some files in the /etc/sudoers.d/ folder to allow things to happen via the pi user without prompting for a password when sudo is used.

pi@octopi:~ $ ls -l /etc/sudoers.d
total 44
-r--r----- 1 root root  36 Nov 26  2018 010_at-export
-r--r----- 1 root root  28 May  7  2018 010_pi-nopasswd
-rw-r--r-- 1 root root  35 May  7  2018 octoprint-service
-rw-r--r-- 1 root root  32 May  7  2018 octoprint-shutdown
-r--r----- 1 root root 958 Jun  5  2017 README
-rw-r--r-- 1 root root  36 Apr  2 11:52 reboot

Thanks for the replies. I tried adding 'pi' to the gpio group.
It said it was already a memory of the gpio group.

I tried the rpi_ws281x repo on github, and ran it w/o sudo on pin 10 (the SPI pin)
but no response from the LED. I connected the LED string to pin 24 on the 3B+ header.
Edited the to make sure I was using pin 10. still No luck.

Next I changed the python script to use GPIO 18 (for the PWM). Moved to pin 12 on the 3B+ header,
and ran the python script as sudo. It worked!

So either I need to crack the code on using the SPI pin, or get octoprint running as root. I realize this is a security issue, but my printer is behind a firewall, and has smoke detectors on it...

Any suggestions are greatly appreciated.


I had the same Problem with pin 10, have you already enabled SPI?

If not, type "sudo raspi-config" go to Interfacing Options -> SPI -> Enable Yes

That solved my Issue...


Hi did you g’et it up to run? And if how did you?

Best regards.


Hi :slight_smile:

This is a pretty old thread and @arlawrence was last seen two years ago.

Please make a new post and put everything relevant to the question it :slight_smile: