Wake-on-LAN API
Send a Wake-on-LAN (WOL) magic packet to power on your homelab server.
Endpoint
Section titled “Endpoint”POST /api/wolAuthentication
Section titled “Authentication”Requires bearer token in Authorization header.
Authorization: Bearer <token>Request
Section titled “Request”No request body required. The target MAC address is configured via environment variables.
Response
Section titled “Response”Success (200 OK)
Section titled “Success (200 OK)”{ "success": true, "message": "Wake-on-LAN packet sent"}Unauthorized (401)
Section titled “Unauthorized (401)”{ "error": "Invalid or expired token"}Server Error (500)
Section titled “Server Error (500)”{ "error": "Failed to send WOL packet: ..."}How It Works
Section titled “How It Works”- articwake constructs a WOL magic packet:
- 6 bytes of
0xFF - 16 repetitions of the target MAC address
- 6 bytes of
- Sends the packet via UDP port 9 to the broadcast address
- Your server’s NIC receives the packet and powers on the system
Configuration
Section titled “Configuration”The target MAC and broadcast address are configured via environment variables:
ARTICWAKE_HOMELAB_MAC="aa:bb:cc:dd:ee:ff"ARTICWAKE_HOMELAB_BROADCAST="255.255.255.255"Example
Section titled “Example”curl -X POST http://localhost/api/wol \ -H "Authorization: Bearer $TOKEN"JavaScript (fetch)
Section titled “JavaScript (fetch)”const response = await fetch('http://localhost/api/wol', { method: 'POST', headers: { 'Authorization': `Bearer ${token}` }});
const result = await response.json();console.log(result.message);After Sending
Section titled “After Sending”After sending a WOL packet:
- Wait ~10-30 seconds for the server to power on
- Poll
/api/statusto check when the server becomes reachable - Once
initrd_ssh_openistrue, you can send the unlock command
# Send WOLcurl -X POST http://localhost/api/wol -H "Authorization: Bearer $TOKEN"
# Wait and check statussleep 15curl http://localhost/api/status -H "Authorization: Bearer $TOKEN"Troubleshooting
Section titled “Troubleshooting”WOL packet sent but server doesn’t wake
Section titled “WOL packet sent but server doesn’t wake”- BIOS settings: Ensure Wake-on-LAN is enabled in BIOS/UEFI
- Network configuration: Some NICs need WOL enabled in the OS before shutdown
- Broadcast address: Try setting
ARTICWAKE_HOMELAB_BROADCASTto your subnet’s broadcast (e.g.,192.168.1.255) - Same subnet: WOL typically requires the sender to be on the same subnet as the target
- Power state: Server must be in S5 (soft-off) state, not hard powered off
Testing WOL manually
Section titled “Testing WOL manually”# Install wakeonlan toolapt install wakeonlan
# Send test packetwakeonlan aa:bb:cc:dd:ee:ff