How to Shut Down a Raspberry Pi Remotely

Most Raspberry Pis are used for a dedicated purpose, for a specific application. The setup may well be headless, without a monitor, keyboard, or mouse. To shut down these Pis, unplugging the power is not recommended. It will result in a corrupted microSD card, sooner or later.

Sign up forfree

Forgot your password?

Create an account

*Required: 8 chars, 1 capital letter, 1 number

By continuing, you agree to thePrivacy PolicyandTerms of Use.You also agree to receive our newsletters, you can opt-out any time.

4

Remotely Shut Down a Raspberry Pi: Desktop GUI (VNC)

Virtual Network Computing (VNC) will show the desktop of the remote computer. VNC Server by RealVNC is already built into Raspberry Pi OS; you need to enable it, though. Navigate toMenu > Preferences > Raspberry Pi Configuration.

In theInterfacestab, toggle the VNC option to on and reboot the Pi. VNC Server should start automatically at the next boot.

Raspberry Pi with hand holding the power cable

From your remote computer, connect to the Raspberry Pi using VNC Viewer (downloadable fromRealVNC) and shut down the Raspberry Pi remotely: go toMenu > Shutdown > Shutdown.

Shut Down Raspberry Pi Remotely Via SSH

Install SSH, andconnect to the Raspberry Pi using SSH.

Then issue theshutdowncommand:

article limit background

Since you are going to shut down, it is often useful to update and upgrade the OS before shutdown. By doing so, the Pi stays up-to-date with security patches.

Shut Down Raspberry Pi From Outside the Network

Connecting to a Raspberry Pi on the same network is straightforward. But, when you want to do it from outside the network, you need to set up port forwarding at the router.

Assuming that you are using the default port 22 for SSH, you need to forward requests on this port to the IP address of your Raspberry Pi. Log in to your router, find the port forwarding option, and set it up. The internal and external ports are 22; the IP address is that of your Pi.

Selecting Raspberry Pi Configuration from the Preferences menu

Once done, you could connect to the Pi using its public IP address. Then, issue theshutdowncommand, as you would do from your computer on a local network.

You can also do this for the GUI when using VNC, in which case you need to forward port number 5900.

Enabling SSH and VNC in the Raspberry Pi Configuration tool

Make sure you have the security setup right when opening your Raspberry Pi to the outside world.Fortify the security of the Raspberry Pi’s Linux-based OS using these best practices.

Shut Down the Raspberry Pi Completely

You can issue the software shutdown command remotely. However, the power supply of the Pi is still switched on and will not shut down unless the power adapter is turned off. You can do this using a relay, controlled by a signal from the GPIO pins, but it’s a complex process.

One way to get around this is by using a high-capacity power bank as the power source. Raspberry Pi consumes little power and so can run for a long time using a power bank. The latter should automatically shut off when the power draw is less than 30mA. So, once you have shut down the Pi, the power bank will auto-shutoff.

Safely Shut Down Your Raspberry Pi: Success

The Raspberry Pi is a great choice for implementations where low power consumption is essential. However, you do need to make sure it shuts down correctly to avoid possible corruption of its SD card. It’s also advisable to back up the data from the card, just in case.

Don’t flash the basic Raspberry Pi OS each time you need a new SD card.

Now, I actually finish the books I start.

Flagship price, mid-range phone.

Your phone is a better editor than you give it credit for.

Anyone with more than a passing interest in motorsports must see these films.

Free AI tools are legitimately powerful; you just need to know how to stack them.

Technology Explained

PC & Mobile