Raspberry Pi NUT Server: Shut Down a NAS and PCs from One UPS

Plug the UPS's USB cable into the Pi, install NUT, and run it as the primary: the one machine that owns the UPS and tells every other machine when to shut down. Name the UPS ups and add a monuser account so a Synology can join. Then make the Pi the last machine to shut down, because its shutdown is what tells the UPS to cut and restore power.

On this page
  1. What a NUT server is, and why a Pi suits the job
  2. How much battery the Pi itself uses
  3. Worked through: a Pi, a Synology and a desktop on one UPS
  4. Why the Pi must shut down last
  5. SD cards and a clean shutdown
  6. The Pi-specific settings
  7. Pointing the NAS and PCs at the Pi
  8. Test it, then fix what breaks
  9. What this page does not cover
  10. Frequently asked questions

What a NUT server is, and why a Pi suits the job

Network UPS Tools (NUT) is the open-source program most NAS and Linux systems use to watch a UPS. A UPS has one USB data cable, so only one machine can read it. That machine is the NUT server. It runs a driver that talks to the UPS and a small service (upsd) that shares the UPS status on TCP port 3493.

Every other machine is a client. It connects to the server over the network and shuts itself down when the server says so. NUT calls the server's own monitor the primary and the clients secondaries. The upsd.users manual puts the difference in one line: the primary "may request FSD" (a forced shutdown of everyone), and a secondary "follows critical situations to shut down when needed."

A Raspberry Pi is a good server for three reasons. It is always on anyway. It draws a few watts, so it barely shortens the runtime. And it has no other job that has to finish first, so it can stay up while the NAS and PCs leave. The file-by-file setup is in our NUT setup guide. This page covers only what changes when the server is a Pi.

How much battery the Pi itself uses

Raspberry Pi publishes current figures for each model. They are taken at the board's 5.1 V input, so watts are amps times 5.1. The figures leave out USB devices and HATs, and the power adapter loses a little more on the way from the wall.

Raspberry Pi current from Raspberry Pi's power supply documentation, converted to watts at 5.1 V
ModelIdle (avg)Stress (avg)Typical bare-boardRecommended supply
Pi Zero 2 Wnot listednot listed350 mA (1.8 W)2 A
Pi 3 Model B0.30 A (1.5 W)0.85 A (4.3 W)400 mA (2.0 W)2.5 A
Pi 4 Model B0.6 A (3.1 W)1.2 A (6.1 W)600 mA (3.1 W)3.0 A
Pi 5not listednot listed800 mA (4.1 W)5.0 A

A NUT server spends nearly all its time idle. So plan on 2 to 4 W for the Pi. That is small next to a NAS or a PC, and it is why the Pi can afford to stay up longest.

Two Pi details matter here. First, the Pi's power adapter must plug into a battery outlet on the UPS, not a surge-only one. Second, the Pi needs a good adapter even on a UPS. Every model since the B+, apart from the Zero range, logs a warning when its supply drops below 4.63 V. Raspberry Pi's own note says a weak supply "can corrupt storage."

Worked through: a Pi, a Synology and a desktop on one UPS

Take a small home setup and walk it through the figures. Suppose these loads, measured at the wall with a plug-in meter. They are made-up numbers for the walkthrough, so measure your own with how to measure power draw.

  • Raspberry Pi 4 as the NUT server: 3 W
  • Synology NAS: 40 W
  • Linux desktop PC: 120 W
  • Router and switch: 20 W

That totals 183 W, on a CyberPower CP1500PFCLCD. CyberPower rates it at 10 minutes at 500 W, which is about 83 Wh delivered (500 W x 10/60 h). Straight scaling to 183 W gives about 27 minutes. Lead-acid gives a little more at light loads, as our runtime explainer shows, so treat 27 as an estimate. The Pi's share of the load is under 2 percent.

Now set each machine's exit time. The desktop leaves first, on a 2 minute upssched timer. The Synology enters Safe Mode on a 3 minute fixed timer, in the 2 to 5 minute range our Synology guide suggests. By about minute 4, only the Pi, the router and the switch are still running.

The Pi goes last, at minute 10 on its own timer. It raises FSD, finds no clients left to wait for, and shuts down. As it halts, it sends killpower. The CyberPower turns its output off 60 seconds later, which is the driver's default delay for CyberPower units. The router and switch go dark at about minute 11, with more than half the battery left.

When mains returns, the UPS turns its output back on. The Pi boots because it gets power. The Synology boots if its restart-after-power-failure option is on, and the desktop if its BIOS is set to power on after AC loss. If you want the router up for the full 27 minutes, let the Pi wait for the UPS's low battery signal instead. Only do that once a runtime test has shown how much is left when that signal arrives.

Why the Pi must shut down last

The order is not a style choice. The upsmon manual says the primary waits for the secondaries to disconnect "before upsdrvctl shutdown runs locally on the primary system and turns them all off." It also warns: "Your secondary systems must all quiesce and shut down before the primary turns off the shared power source, or filesystem damage may result."

So the primary does two jobs at the end. It waits for every client, up to HOSTSYNC (15 seconds by default). Then its own shutdown sends killpower, the command that makes the UPS cut its output after a delay. That power cycle is what makes unattended recovery work. A Pi that has halted but still has power stays off. Raspberry Pi's power button page says a Pi 5 in that state restarts when you press the button. A halted NAS behaves the same way, because its "power on after AC loss" setting never sees a loss.

The other answer you will find

Some guides skip the Pi's shutdown on purpose. Kurt Shuler's homelab notes leave SHUTDOWNCMD out of the Pi's upsmon.conf, because the author wants the Pi "to stay up as long as the battery lasts rather than shut itself down." That buys monitoring until the end. It also gives up two things.

First, the Pi loses power with no warning when the battery dies, which is the storage risk Raspberry Pi warns about. Second, if mains returns after the NAS has halted but before the battery dies, nobody sends killpower. The UPS output never drops, so the halted NAS stays off until someone presses its button. Our ruling: give the Pi a real shutdown, and make it the last one.

Our rule of thumb: count the minute after low battery

If the Pi waits for low battery, the end of the sequence still needs time. Add HOSTSYNC (15 s), FINALDELAY (5 s), the Pi's own shutdown and the UPS's off delay (60 s on CyberPower). That is well over a minute and a half of battery after the signal. If you have not measured what remains at low battery, give the Pi a fixed upssched timer that runs upsmon -c fsd. The manual names upssched as the way to start a shutdown "before the critical stage."

SD cards and a clean shutdown

Most Pis boot from a microSD card. Raspberry Pi's documentation is direct about the risk: "power dropouts can cause storage corruption." It points to a white paper, Making a more resilient file system, for file system choices that help. A clean shutdown is the simplest defense, and on a UPS you get one for free if the Pi has a real SHUTDOWNCMD.

That matters more on a NUT server than on most Pis. If the card corrupts, the next outage finds no server. Every client then loses contact. A client that cannot reach its server only shuts down if the UPS was last seen on battery, which is a fallback rather than a plan. If you move the Pi to a USB SSD, add the drive's draw to the table above. Raspberry Pi lists external drives among the high-demand USB devices.

One more Pi 5 detail. Raspberry Pi says a Pi 5 draws "around 1 W to 1.4 W" when turned off. Adding POWER_OFF_ON_HALT=1 to the EEPROM settings drops that to about 0.01 W. On a UPS that cuts its output after the Pi halts, those last seconds hardly matter, so this setting is optional.

The Pi-specific settings

Install Raspberry Pi OS Lite, connect the Pi by Ethernet, and give it a fixed address. Install the nut package, which on Debian-based systems pulls in the server and the client. Then set MODE=netserver in nut.conf. The NUT guide walks through each file. These are the lines that differ on a Pi serving a Synology:

# /etc/nut/ups.conf  (section name must be "ups" for a Synology)
[ups]
    driver = usbhid-ups
    port = auto
    # pollinterval = 10   # only for "control timeout on ep0in" errors
    # pollonly            # only if a CyberPower unit's data goes stale
    # offdelay = 60       # CyberPower: never lower than 60

# /etc/nut/upsd.conf
LISTEN 127.0.0.1 3493
LISTEN 192.168.1.5 3493     # the Pi's LAN address

# /etc/nut/upsd.users
[upsmon_local]
    password = ChangeThis
    upsmon primary
[monuser]
    password = secret
    upsmon secondary

# /etc/nut/upsmon.conf  (on the Pi)
MONITOR ups@localhost 1 upsmon_local ChangeThis primary
SHUTDOWNCMD "/sbin/shutdown -h +0"

Keep the POWERDOWNFLAG line your package ships. It is what tells the late shutdown stage to send killpower. On NUT older than 2.8, write master and slave instead of primary and secondary.

The three driver flags, and when you need them

The usbhid-ups manual lists these as known issues, not default settings. Leave them commented out until you see the symptom.

  • pollinterval sets how often the driver refreshes the UPS status. The ups.conf manual gives the normal value as 2 seconds. If the log fills with control timeout on ep0in, the manual says to raise it "to a higher value (such as 10 seconds)." Past 10 or 15 seconds, raise pollfreq by the same factor.
  • pollonly stops the driver from waiting for the UPS to push changes, and asks for each value instead. Some controllers "fall asleep" when not contacted for a while. The manual says "CPS devices are commonly associated with such behaviour." CPS is CyberPower Systems.
  • offdelay is the wait between killpower and the UPS cutting its output. The default is 20 seconds, or 60 for CyberPower. Many CyberPower models divide it by 60 and round down. So 60 is "the minimum advisable value," or the UPS may switch off the moment the Pi sends the command.

Pointing the NAS and PCs at the Pi

Each client needs the Pi's address, the UPS name, a user and a role. This table only restates what each linked guide covers in full.

Who does what on a Pi-served UPS
DeviceNUT roleWhen it shuts downSetup
Raspberry Pi (USB cable)Primary, netserverLast, after every client has disconnectedThis page
Synology NASSecondary via "Synology UPS server"Safe Mode on a fixed timer, 2 to 5 minutesSynology UPS setup
Proxmox or other Linux hostSecondary, netclientEarly, on an upssched timer, before any NAS that holds its disksProxmox UPS shutdown
Home AssistantMonitor only, through the NUT integrationNot by NUT; it sends alertsHome Assistant UPS monitoring
Router and switchNoneWhen the UPS cuts outputBattery outlets only

The Synology needs nothing beyond the Pi's IP, because the Pi already offers ups, monuser and secret. A Linux client gets MODE=netclient and one line: MONITOR ups@192.168.1.5 1 monuser secret secondary. A plain secondary only leaves when the Pi declares the UPS critical. So any machine that must leave early, like a hypervisor using NAS storage, needs its own timer. In Home Assistant, add the NUT integration with the Pi's address and port 3493. Use it for alerts, and leave the shutdowns to each machine's own NUT client, as our Home Assistant guide advises. The router and switch stay up so the clients can still hear the Pi. For sizing a whole lab around this, see UPS for a homelab server.

Test it, then fix what breaks

Run upsc ups@localhost on the Pi, then upsc ups@192.168.1.5 from a client. Both should show ups.status: OL. Then, at a planned time with work saved, run upsmon -c fsd on the Pi. The usbhid-ups manual says that with mains present, this "should bring your systems down and then cycle the power to restart them again." Without mains, the outputs stay off until mains returns.

Pi NUT server problems and fixes
SymptomLikely causeFix
Log shows control timeout on ep0inThe UPS is slow to answer at the default polling ratepollinterval = 10 in ups.conf (usbhid-ups manual)
CyberPower data goes stale after a whileThe UPS controller falls asleepAdd pollonly, or keep pollfreq and pollinterval small (usbhid-ups manual)
CyberPower cuts power the instant the Pi haltsoffdelay under 60 rounds down to zerooffdelay = 60 or more (usbhid-ups manual)
Synology cannot connectSection not named ups, no monuser, or upsd on 127.0.0.1 onlyFix ups.conf, upsd.users and upsd.conf as above (Synology guide)
Under-voltage warnings in the Pi's kernel logWeak Pi power adapter or cableUse a better supply (Raspberry Pi documentation)
NAS stays off after a short outageNo killpower, so the UPS output never droppedGive the Pi a real SHUTDOWNCMD and keep POWERDOWNFLAG

If the Pi does not see the UPS at all in lsusb, the problem sits below NUT. Start with UPS not detected by computer.

What this page does not cover

The Pi figures are Raspberry Pi's bare-board numbers. They leave out USB drives, HATs and adapter losses, so measure your own Pi if the margin is tight. The 27 minute runtime in the worked example is scaled from one spec-sheet figure, not measured. The CyberPower notes come from NUT's manual, which also reports models that need offdelay = 0 before the load comes back after power returns. Which kind you have is something only the upsmon -c fsd test will show. This page does not cover Windows clients, UPS units with a network card, or running two UPS units from one Pi. It also cannot tell you when your UPS raises low battery. Measure that with a runtime calibration before you let any machine wait for it.

Frequently asked questions

Which Raspberry Pi is good enough for a NUT server?

Any model that runs current Raspberry Pi OS and has a USB port and a network link will do the job, because NUT itself is light. A model with wired Ethernet is the better choice, since the clients reach the Pi over the network. A Pi 3B or Pi 4 idles at 0.30 A or 0.6 A in Raspberry Pi's own table, so the smaller boards cost very little battery.

Can the Pi run Home Assistant and be the NUT server at the same time?

Yes, if the UPS cable plugs into that Pi. On Home Assistant OS you run the NUT add-on as the server and point the NUT integration at it. Keep machine shutdowns in each machine's own NUT client, not in Home Assistant automations. Our Home Assistant guide covers that layout.

Why does my Synology not see the Raspberry Pi UPS server?

DSM only asks for the server's IP. It assumes the UPS name is ups, the user is monuser and the password is secret. So the Pi needs a [ups] section in ups.conf, a [monuser] account in upsd.users, and upsd listening on its LAN address, not only on 127.0.0.1. Test with upsc ups@pi-address from another Linux machine first.

Does the Raspberry Pi turn back on by itself after the outage?

A Pi boots when power is applied. Raspberry Pi's documentation says it turns on without the button when first plugged in. A Pi that has halted but still has power stays off until the power cycles or, on a Pi 5, until someone presses the button. That is why the UPS must cut and restore its output after the shutdown.

Should the Pi use Wi-Fi or Ethernet?

Ethernet. Every client reaches the Pi over the network during the outage. Wired Ethernet means only the switch has to stay powered, not a wireless access point as well. Give the Pi a fixed address either way, since every client stores it.

Sources and further reading

  1. Raspberry Pi documentation: Power supply (typical power requirements, current by workload, Pi 5 power when off, low-voltage warnings)
  2. Raspberry Pi documentation: Power button (boot on power, restart from halt)
  3. NUT usbhid-ups(8) manual: offdelay, pollfreq, pollonly and known issues
  4. NUT ups.conf(5) manual: pollinterval
  5. NUT upsd.users(5) manual: upsmon primary and secondary
  6. NUT upsmon(8) manual: primary and secondary, HOSTSYNC, upsmon -c fsd
  7. CyberPower CP1500PFCLCD spec sheet: runtime at half load 10 min, two 12 V 9 Ah batteries
  8. Kurt Shuler, Homelab Docs: NUT server on a Raspberry Pi