You set the service to run unattended and the task to fire at startup. None of that matters if the machine underneath is off. A power blip, a sleep timer, or a reboot nobody was there to wake it from, and the box is dark while every careful remedy you configured waits patiently for a computer that isn’t on.
If you’ve read about keeping a background service alive, this is the layer beneath it. Making a service start without a login, restart when it crashes, and survive a reboot is all necessary, and all pointless the moment the physical machine is powered down. A server on an old laptop or mini-PC is especially prone to this, because its defaults are built for a device someone carries and closes, not one that sits in a cupboard and must never stop.
Table of Contents
It falls asleep
The most common way an “always-on” box isn’t is that it went to sleep. Consumer operating systems ship with sleep timers tuned for a personal machine, and a server inherits them. An idle box dims, sleeps, and drops off the network, and from the outside that is indistinguishable from a crash.
On a machine meant to run unattended, turn sleep and hibernate off outright for the plugged-in power state:
# Never sleep or hibernate on wall power (0 = never)
powercfg /change standby-timeout-ac 0
powercfg /change hibernate-timeout-ac 0
Code language: Bash (bash)
The reference for every flag is Microsoft’s powercfg documentation. Do the same thing in the BIOS or firmware if it has its own sleep or low-power option, because a firmware sleep state can override the operating system’s.
It loses power and stays off
A power cut is the failure people forget, because it only bites when they aren’t watching. The machine loses power, the outage passes, power returns, and the box stays dark, because the default behavior of most hardware after an AC loss is to remain off. It is waiting for a human to press the power button, and if the machine lives in a cupboard and you’re on the other side of the city, that human never arrives.
Two settings fix this, and they complement each other:
- “Restore on AC power loss” in the BIOS. Nearly every desktop and mini-PC firmware has a setting, usually under Power or ACPI, with options like Power Off, Power On, and Last State. The default is often Power Off. Set it to Power On (or Last State if the box is normally on), and when power returns the machine boots itself. This one setting is the difference between an outage that self-heals and one that needs a house call.
- A small UPS. A battery backup rides out the short blips and brownouts that would otherwise reboot the machine for no reason, and on a longer outage its monitoring software can trigger a graceful shutdown before the battery dies, so the machine powers down cleanly instead of being cut off mid-write. Pair the UPS with “restore on AC power loss” and the cycle is complete: the UPS absorbs the short events, and the BIOS setting brings the box back after the long ones.
Mains power is lost. Default hardware behavior: the machine stays off.
Battery carries a short blip with no reboot; on a long outage, triggers a clean shutdown before it dies.
BIOS 'restore on AC loss' = Power On: the machine boots itself and services auto-start. No one present.
Without the BIOS setting the box stays dark until someone presses the button; without a UPS a long outage cuts it off mid-write.
It’s off, and you’re not there to turn it on
Sometimes the machine is legitimately off (you shut it down, or it hasn’t been set to auto-power-on) and you need it on while you’re away. That is what Wake-on-LAN is for: the network card stays listening on standby power, and a specially formed “magic packet” addressed to its MAC wakes the machine.
It takes enabling in two places, the firmware and the operating system’s network-adapter settings (look for “Wake on Magic Packet” / “Allow this device to wake the computer”), and then any client on the network can send the packet:
# Wake a machine by its network card's MAC address
wakeonlan 01:23:45:67:89:abCode language: Bash (bash)
Two caveats keep people stuck. First, a magic packet is a broadcast, so by default it only crosses the local network segment; to wake a home machine from the internet you either forward the packet through the router or send it from another always-on device already on the LAN. Second, Wake-on-LAN wakes a machine that is sleeping or soft-off; it cannot turn on a machine with no standby power, so “restore on AC power loss” and a UPS matter for the power-cut case. The two mechanisms cover different states, and a genuinely resilient box has both.
Know when it’s dark
All of the above makes the machine recover on its own. The last piece is learning when it doesn’t, without driving over to check. A lightweight heartbeat, the box reporting in on a schedule, or an external uptime check that pings a service it hosts, turns “I found out it was down when I needed it” into “I got a message the moment it stopped.” It doesn’t keep the machine up, but it means a failure that slips past every automatic recovery doesn’t also slip past you. That is a small topic of its own, but worth setting up the same day you set up the rest.
The short version
A service is only as always-on as the machine under it, and a machine goes dark in ways software can’t reach: it sleeps, it loses power and stays off, or it’s off while you’re away. Turn sleep and hibernate off, set the BIOS to power back on after an AC loss and add a UPS for the short blips, and enable Wake-on-LAN to bring the box back remotely. Then add a heartbeat so you hear about the failures that still get through. Set once, and the machine looks after its own availability instead of waiting for you to walk over.
Frequently Asked Questions
My always-on server won’t power back on after an outage. How do I fix it?
Change the BIOS/firmware setting for behavior after an AC power loss. It defaults to “Power Off” on many machines, which is why the box stays dark after the power returns; set it to “Power On” (or “Last State” if the machine is normally running) and it will boot itself when power comes back. Add a UPS as well, so a brief blip doesn’t reboot the machine at all and a long outage can trigger a clean shutdown. The two together are what make a power cut self-healing.
Does Wake-on-LAN work over the internet?
Not on its own. A Wake-on-LAN magic packet is a local broadcast, so by default it only reaches machines on the same network segment as the sender. To wake a home machine from outside, either configure the router to forward the packet to the target, or send it from a second device that is already on the home network and reachable remotely. Many people use a small always-on device, a router with the feature built in, or a mesh network for exactly this relay.
What’s the difference between Wake-on-LAN and “restore on AC power loss”?
They cover different “off” states. “Restore on AC power loss” is a firmware setting that boots the machine when mains power returns after an outage, so it needs no network and no sender. Wake-on-LAN wakes a machine that is sleeping or soft-off but still has standby power, on demand, by sending it a packet. Wake-on-LAN can’t start a machine that has no power at all, which is why a resilient always-on server uses both: the AC setting for power cuts, Wake-on-LAN for deliberate remote starts.
Do I really need a UPS if the BIOS already restores power?
They solve different problems. “Restore on AC power loss” brings the machine back after an outage, but the outage still cut it off mid-operation, which risks a corrupt write or a filesystem that needs checking on the next boot. A UPS prevents the hard cut in the first place for short events, and buys time for a clean shutdown on long ones. On a machine doing real work, especially one with a database, the UPS is what turns a hard power loss into an orderly one; the BIOS setting is what brings it back afterward.