Shutdown doesn't stick

I'm running OctoPi on a Raspberry Pi 3B+. I installed using the instructions at - Download & Setup OctoPrint.

When I try to shut it down, it immediately restarts -- doesn't matter whether I use the Octoprint menu or shutdown -h now from sudo.

At first I thought it was maybe configured to restart on lan access, so I always power off my printer (Prusa i3 MK3), log out of Octoprint, close the Octoprint browser tab, ssh to the pi and shutdown from the command line. The green light flashes for a while, then goes dark. After a minute or so, the red light goes dark for a split second. Then it reboots.

What do I need to change to make it shut down properly?

I'd suspect the power supply. Normally, the red led does not go out after a shut-down. If the voltage drops below a certain level and then returns, it will boot up. Also check the USB power cable, I've had cases where a poor quality or faulty cable affects the power.

Share your octoprint.log.

If you know how to ssh, it'd be interesting to see the uptime and various logs too.

What about sudo poweroff?

Disconnect the printer and see if this fixes it. If so, then it sounds like the printer (or anything USB-based) is back-powering the Pi.

I considered that it might be the USB keeping it alive so I started powering off the printer before I shut the Pi down. No change.

Hi @Brenda_Bell

You may try this: restart in Save Mode and then Shutdown.
If it works, then a plugin seems to be the issue.

I'll try to get logs the next time it happens. That said, it's interesting that you mention uptime. I've noticed that when I leave it running for more than a day, weird things happen like losing its connection to the printer. Last night I booted up, did a small print, disconnected the browser, powered off the printer, did the shutdown and it stayed off.

So along with the other folks here, I'm now starting to suspect the power supply as well.

Put everything on a UPS. It's possible from what you've described that you're having brownouts on your building's power.