I have a cluster of Pis that sometimes one of them fails and I cannot access it remotely until I come to the device and unplug and plug it again. I want a solution that if a Pi fails, I can remotely restart it. I learned that some people use a button in between for restarting but this still needs me to be present. I also see that some people connect GPIO 3 + Ground to restart using a button in between. But, this solution also needs access to the Pi which is impossible when it has failed. Is there a way that I can restart the Pi by connecting a wire from its pins to the pins of a spare Pi and command the spare Pi to reboot the failed Pi? I mean everything by coding without a button or relay, so it does not need me to be present for a reboot.

A working example. I have two Pi 3. I wire is connected on one end to the first Pi on GPIO 17 and on the other end on the 'Run' pin. I have the following code on the first Pi.

#!/usr/bin/env python3
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)  # set the pin numbering scheme to BCM
GPIO.setup(PIN, GPIO.OUT)  # set up GPIO 17 as an output

GPIO.output(PIN, GPIO.LOW)  # trigger the restart by pulling GPIO 17 low
time.sleep(1)  # wait for 1 second
GPIO.output(PIN, GPIO.HIGH)  # release GPIO 17 to allow the Raspberry Pi to start up
# release the GPIO channel

TBH, I got this from ChatGPT. When I run this code, the second Pi gets restarted. I think this is considered a hard restart. My question is that,

  • 1- Is this an appropriate solution to get a crashed Pi that you cannot even SSH to back?
  • 2- Is there a better way to soft restart the second Pi using the first Pi? (Assume the second Pi has crashed and we cannot SSH and we do not want to physically unplug or change wirings)
  • 3-This only worked on Pi 3 and did not work on Pi 4, why?
  • The Pi4 (& Pi3+) have different circuitry but the RUN pin should work similarly and reset SoC (study the schematics). It should work if you use a transistor to emulate a push button. It is EXTREMELY INADVISABLE to connect foreign 3.3V to the RUN pin; this is likely to interfere with the operation of the PMIC (you risk destroying the PMIC). Both have a GLOBAL_EN (PEN) connection on J2 header (although the circuitry differs) which can be used to control the PMIC (NOTE this uses 5V logic) - the same caution about connecting foreign voltage to the pin applies.
    – Milliways
    Apr 9, 2023 at 12:50
  • NOTE the RUN pin on Pi3+ & Pi4 is an OUTPUT of the PMIC.
    – Milliways
    Apr 9, 2023 at 13:16

2 Answers 2


The simple answer is no (at least if I understand your rather vague question).

https://raspberrypi.stackexchange.com/a/77918/8697 describes the gpio-shutdown which I have enabled on all my Pi.
Pulling this low will safely shutdown the Pi (even if it is unresponsive).
If you use pin 3 it may be possible to reboot (but you would need to program a delay - at least 90 seconds) before boot.

There is a hardware solution which should boot the Pi (even if it is running) but this is a hard reset which risks data loss. Restart is instantaneous.

This does NOT use GPIO but the separate (unpopulated) J2 header (confusingly named RUN). On my older Pi (including Pi3) I used to wire a push button to this header to restart.

See https://raspberrypi.stackexchange.com/a/136776/8697

NOTE in ANY of these solutions if I was not using a physical button I would use an open collector transistor as interconnecting GPIO pins between Pi is risky.

NOTE The Pi SoC has an on-board watchdog timer. I assumed anyone running a remote system would already have this running. I run on most of my Pi (but still have occasional unresponsive Pi).

  • 1
    Thanks for your reply. I updated the question with additional explanations. Apr 9, 2023 at 11:52

Last I checked, what you want to do is possible, but I haven't (and will not) try to debug your code. This is made possible by the Device Tree Overlay (DTO) known as gpio-shutdown. You can find a description (i.e. the documentation, such as it is) in the Raspberry Pi GitHub page - search in page for "gpio-shutdown".

The gpio-shutdown DTO was developed by a clever fellow named Matthijs Kooijman, as described here in an old blog post; it is sometimes called the "One Button ON-OFF" feature. It's been re-jiggered a bit to accommodate other firmware changes, but AFAIK - it still works.

As you've said, you need to remotely trigger the button press, but as the switch is a simple SPST pushbutton, you should be able to replicate that via a set of relay contacts - or perhaps via a transistor if you are willing to connect the GND pins on the two RPi. In any case, it's easy enough to try this.

The only thing I know of that will preclude operation of this "One Button ON-OFF" feature is if you have enabled the I2C1 interface; this being due to the unique nature of GPIO3, and the fact that it is also used as the default I2C. If you're using I2C, you will need to move it from I2C1 to I2C0 to free up GPIO3. I see nothing in the "documentation" excluding RPi 4, so it should work the same as on RPi 3.

There are some older posts on this subject that might help:

  1. Answer dtd Oct 10, 2021

  2. A different approach is in this answer from Dec 16, 2021 in which you can simply replace the PB switch with a relay or transistor.

  3. For RPi 4 the GLOBAL_EN node may also be used to re-start

Let us know if you have questions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.