BLOG > Raspberry Pi Remote Wake/Sleep-On-LAN Server

A Wake/Sleep-on-LAN Server Powered by a Pi!
A Wake/Sleep-on-LAN Server Powered by a Pi!

Note: This post and the accompanying software packages have been updated several times since this was originally posted. The most up-to-date releases and instructions can always be found in the GitHub Repo. Update notes are appended to the end of this blog post. The V3 Beta release automates most of the setup process, incorporates Dynamic DNS Auto-Updating, and supports signed HTTPS.

I have a very power hungry desktop computer. When I’m travelling with my laptop, I can’t carry all my files and data with me, so I occasionally use “remote desktop” to access my desktop from the road. I also use a Plex Media Server to stream content from my desktop computer. However, the computer has to be on for me to be able to do this. This means I need to leave the computer on all the time, just in case I need to access it. This wastes power, costs me money, and harms the environment. My Raspberry Pi, on the other hand, consumes a minuscule amount of power, and is always on anyways, serving other purposes. In this tutorial, I’ll show you how to run a simple mobile-friendly website from your Raspberry Pi that will allow you to remotely wake up your power-hungry computer, so you can remotely access it. When you’re done, just put it back to sleep from within the remote desktop service (or use the mobile app plus a small background server running on your desktop to put it back to sleep – this is described in the instructions). The app pings the computer from the Raspberry Pi to inform you of when the computer has woken up and established network connectivity. Follow along after the break…

Once you’re done setting up your Pi-Powered Wake/Sleep on LAN Server, here’s how it will work…

  1. From wherever you are in the world, navigate to your unique, dynamically updating URL (wol.example.com)
  2. You’ll be presented with a screen that looks like the one below (note, you may get a security popup first, if you choose to use a self-signed certificate to enable HTTPS – this is described in the instructions). From this screen, you can select which machine you want to control, and you can view its state (awake or asleep). You can add as many machines that you want to control. Here, you can see that “Phoenix Desktop” is currently awake, and I have the option to put it to sleep:
  3. Next, you’ll enter a passphrase that you’ve pre-chosen. If the wrong phrase is entered, a “denial” note will pop up, and you’ll be able to try again. If you enter the right phrase, the Raspberry Pi can send a “Wake Up” or “Sleep” command to the remote machine. It will then ping that computer and display the results in real-time, so that you know when the computer has finished booting or when it has finished going to sleep. Here, you can see what that screen looks like when I put “Phoenix Desktop” to sleep remotely:
  4. You’ll receive a confirmation message when the computer has finished waking up or going to sleep. If you just woke it up, you can now perform normal remote access tasks, like SSH, FTP, or Windows Remote Desktop.

Ready to set this up for yourself? Visit the GitHub Project Wiki to follow the detailed installation instructions.

Updates:

  • 7/20/2013: Added the ability to put the computer back to sleep using the mobile webapp. Instructions updated on the Wiki.
  • 12/15/2013: The app now includes a dropdown that allows you to pick a computer. You can now Wake/Sleep as many computers as you want! Thanks to GitHub user ahodgey for submitting a Pull Request with most of this functionality (I made some updates to his pull request, and merged it into the master repository branch).
  • 09/14/2015: The Raspberry Pi WOL software now supports self-signed SSL encryption, meaning you can connect over HTTPS using a self-signed certificate. Additional security measures have also been implemented to reduce the risk of XSS vulnerabilities. Thanks to GitHub user felixrr for the Pull Request! You can still use ordinary HTTP if desired, and updated instructions can be found on the Wiki.
  • 01/24/2015: Software bumped to v2.0. Fixed lots of bugs, and confirmed working latest Raspbian Jessie release, with Apache 2.4.x (which had a bunch of breaking changes).
  • 01/31/2021: An x86 Docker Image is now available for this application (for Desktop, not Raspberry Pi). I have not independently validated its performance, but it pulls directly from my Repo. It’s available on DockerHub here.
  • 02/21/2021: The V3 Beta release automates most of the setup process, incorporates Dynamic DNS Auto-Configuration, and supports signed HTTPS. Follow the V3 Wiki Instructions to install it!

Supporting Documentation and Code

This project is licensed the GNU GPL v3.  Please Attribute and Share-Alike. You can download the source directly from the GitHub Repository linked below.

Get it on GitHub

383 comments

  1. I have used my rpi long time for this purpose and it was working very fine. Now I had to reinstall my rpi and followed the instructions again. I replaced php5 with php7.0 where needed (or php/7.0/ in paths)

    The wakeup is working, but.. the pinger is nog getting back into the website… I mean, if I use the passphrase and the Wake UP! button, my PC wakes up, but the page never shows the “It’s Alive!”

    What could that be ?

    1. I wouldn’t bother using SSL for this project, my advice is to reconfigure it again skipping the https/ssl part, that’s how I did it. You are not exchanging any sensitive data, so I don’t see the point.

      1. The passwors is the “sensitive data” so there definately is a point of doing it. Try waking up your computers on a shady unencrypted WiFi and then wonder why your computers start wakeing up in the middle of the night “all by them selves.

        1. That password is only good to wake your PC (unless you are “clever” enough to use the same password for everything). I stay away from “shady unencrypted WiFis” so that’s not a concern to me either.

          1. People are difference and many DO use same pw and shady wifi. So if you are smart enough it doesn’t mean there’s no point of SSL for others.
            Also if someone already have access to the target computer, it has to be on. And this could potentially be the way of doing just that

  2. Nevermind .. my brain was thinking in the wrong IP range that I use a lot at work and it is very similar to the range at home but slightly differnet

  3. Any of you guys ever found a way to set several different passwords for different computeres?

    Would be amazing if could be done. Imagine its only adding a few more lines to the code.

  4. Hi there Guys,

    Has anyone ever managed to get this working on a DietPi Installation? I love this app and have followed all the instructions and it all works apart from it will not wake a PC, however, the website will confirm that a PC is awake / Asleep and seems to sleep but not wake? any help would be greatly appreciated, guys.

    Many thanks in advance.

  5. I’ve been using this for years on an old model b running wheezy and recently decided to upgrade to the latest version stretch via a clean install but cannot get this to work. It sees my PC and shows it status correctly but does not issue the wake or sleep command to the PC even though it says it has.
    I restored my backup of wheezy to the sd card and its all working again fine.
    As I have a new pi3 now as well I tried installing it on that but the result is the same – the old wheezy server works but the new stretch one does not.
    Any ideas whats going wrong?
    I have read through some of the comments and tried one persons suggestion of adding a – i prefix to the MAC but this made no difference.
    Comparing the index.php files and the config.php files shows no major differences as far as I can see.

    1. The problem might lie on the PC side, I’d try sending WoL packets from your smartphone (there are apps for that) and ensuring it wakes your PC. In my case, after a NIC driver update, it stopped responding to WoL packets, I had to roll back to the previous driver to get it back to working conditions. One other issue I have, that I haven’t yet fixed, I have a dual boot with two partitions, windows and Ubuntu. Whenever I boot to Ubuntu, once I’m done using it and shut it down, the PC won’t respond to WoL packets until I boot into Windows again. Not a big deal, I don’t use my Ubuntu partition that much.

    1. I actually resolved this by changing the php7 links to php5 as it was just failing to properly configure all of the components due to the links being incorrect on some of the lines. It’s now working fine on the rpi1 with Stretch.

  6. Hi, I just did a clean install on a rpi3 with Stretch. I think there is still a mistake in the installation instruction when. In general, the instruction has been updated to reflect the change from php5 to php7. However this line (as of today):

    sudo apt-get install wakeonlan apache2 php git php5-curl libapache2-mod-php

    should be like

    sudo apt-get install wakeonlan apache2 php git php7.0-curl libapache2-mod-php

    This worked for me.

    1. the command “sudo apt-get install wakeonlan apache2 php git php7.0-curl libapache2-mod-php” failed when I tried it, I worked around it replacing “7.0” with “7.3”

  7. I have been using this tool for years on a Raspberry (1)B+. The OS version I was using was really outdated (wheezy), so I tried to update it… big mistake, the upgrade process messed up with apache files and directories and the tool ended up broken. So I downloaded the latest version of Raspbian (Buster lite), and after flashing the SD card and setting up the OS, I followed the tool installation from scratch (no ssh encryption, I had the feeling it was going to give me headaches). It took me a couple hours, but it’s now up and running again. Thanks again, Jeremy.
    PS: the commands regarding to PHP 7.0 will fail, I worked it around replacing 7.0 with 7.3.

  8. Hi,

    one question is it possibel to setup a password per machine?
    Instead of:
    $APPROVED_HASH = “xxx”;
    $COMPUTER_NAME = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_MAC = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_LOCAL_IP = array(“xxx”,“xxx”,“xxx”,“xxx”);
    like
    Instead of:
    $APPROVED_HASH = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_NAME = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_MAC = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_LOCAL_IP = array(“xxx”,“xxx”,“xxx”,“xxx”);

  9. Hi Jeremy,
    can you help me? I have two problems with my WOL-Server.
    1. It does recognize when my clients are on – it keeps waking them up and up and up althougt it already worked – and later when I come back to the site, it tells me the computer is asleep althought it is on

    2. Can I have a password per machine? I tried this but that didnt worked:
    Instead of:

    $APPROVED_HASH = “xxx”;
    $COMPUTER_NAME = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_MAC = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_LOCAL_IP = array(“xxx”,“xxx”,“xxx”,“xxx”);

    I tried

    $APPROVED_HASH = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_NAME = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_MAC = array(“xxx”,“xxx”,“xxx”,“xxx”);
    $COMPUTER_LOCAL_IP = array(“xxx”,“xxx”,“xxx”,“xxx”);

    Why different passwords, I have member that shouldnt be able to turn on certain machines.

  10. *iOS 14.x certificate issue. Community query.*help*.
    Hi All,
    Just want to initially say thank you to Jeremy & Felix for this WOL tool.
    I have been using it for years on a pi and found it endlessly useful.
    I recently purchased a new iPad which is running iOS14.3.
    When I access my https url for my pi WOL server safari displays the, ‘this connection is not private’ message. If I then select ‘show details’ & ‘visit this website’ safari returns to the ‘this connection is not private’ warning page instead of taking me to the WOL server web page.
    I also have an old iPhone running iOS12.x and safari runs fine when accessing the WOL server web page. I believe apple have increased the minimum level of security requirements which is the cause of my issue. What I don’t know is…
    Can I just install and approve the existing self signed certificate to iOS14.x or do I need to generate a new certificate for my WOL server altogether?
    If I can just install the self signed certificate, (& please forgive my ignorance) how do I download/extract the original certificate I generated? I created it years ago and cannot remember anything now.
    To make matters more confusing… the self signed certificate is marked as expired in 2019 but as iOS12 still accepts this I don’t know if that is part of the problem or if it’s a red herring.
    Any advise from the community would be appreciated.
    Regards
    JB007
    The person who wonders what happened to good old fashioned user manuals.

  11. Hi Jeremy,
    Is it possible to run the v3 setup script without the DDNS option? I have to select option 1 or 2 but i don’t want either of them since I’m using this locally without any internet access.

    Also, after selecting one of the options there is no way to ever select another because when re-running the setup script it doesnt ask for it anymore.

    Thanks!

  12. After installing the RWSOLS, the openmediavault web gui can no longer be accessed. I did change the port of openmediavault from 80 to 81, before installing the RWSOLS, to avoid any crash. Any fix for this ? Is it possible to change the port used RWSOLS from 80 to others ? Thanks in advance.

  13. Hi Jeremy,

    I have the latest RWSOLS installed on a RPi4 – all working fine as far as waking up the configured devices.

    I have installed the Sleen-On-Lan exe on a Windows 10 desktop – which does work fine.

    I was wondering if it was possible to configure the RPi code to shut the computer down fully, rather than putting the desktop to sleep ?

  14. Hey,

    When I do the automatic setup script, it won’t let me enter a password at the end. I try entering and nothing shows up. I hit enter a few times trying to type it in and it makes me open the config file (which at this point I’m lost).

    It does say it can’t reach port 80 or 443 (404 not found). Perhaps I need to look at my port forwarding

    1. Hey I know you wrote this ages ago, but it actually is letting you type in the password, but it’s not showing the characters. Type in your password (ignore that nothing is coming up), press enter, and it should ask you to re-enter it to confirm it. Hope that helps!

      1. Yup realized shortly after I was being a dope and it doesn’t show the chars when you type em, thanks for the sweet program! Works great!

Leave a Reply to Barend Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisement