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 (
  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.


  • 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


    1. What do the Apache error logs say? They should be located in:

      Check debug settings in php.ini

      1. I’m having the same problems as Ville. Both with or whit out SSL support, I’m getting an empty webpage.

        /var/log/apache2/access.log show no login attempts
        /var/log.apacht2/error.log showed an error (typo I made in /var/www/html/config.php). Fixed the error.

        I searched for php.ini, but that doesn’t exist on my RaspberryPi

        Help is much appreciated being a newby on raspberryPi and linux. Thanks

    1. Server version: Apache/2.4.10 (Raspbian)
      Server built: Jan 23 2016 22:26:49

      Raspbian Jessie Lite
      Minimal image based on Debian Jessie
      Version: November 2015
      Release date: 2015-11-21
      Kernel version: 4.1

  1. Ok, now it works. Added quotes back to lines:

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

    in the /var/www/html/config.php

  2. Hi,

    Great app! But for some reason the password I have generated is not being accepted by the webpage. I used the website in the config file to generate it but when I enter it in it just says Invalid Passphrase. Request Denied.

    Any ideas why?


  3. Thought I should quickly mention

    As I am a Pi and Linux noob, I wasn’t sure hwo to delve into the inner workings of this project however, I came accross a simple solution to my problem.

    My setup is the Pi connected through wifi to the router, and a crossover cable to my PC. There was no way I could see to determine which network the software was sending the magic packet to, apart from the fact I knew it wasn’t sending it through the ethernet network.

    I could ping both ways through the ethernet connection, and could manually use wakeonlan, but only when I specified the IP address as the broadcast address.

    In my case the command was ‘wakeonlan -i X1:X1:X1:X1:X1:X1:X1’

    which although it seems simple now… took me a little while to try and work out to put the string arguments into the config file, so instead of using just the MAC address as a the only information in the string variable, I used the working complete argument set, hey presto works a treat!

    $COMPUTER_MAC = array(“-i X1:X1:X1:X1:X1:X1:X1”)

    Leave the computer local IP as it should be e.g. as this is used only for pinging (as far as I am aware).

    I thought I should comment as I couldn’t find this information anywhere and it might stump someone as it did me.

    Any other simpler or more robust way to recreate what I have done?


  4. Hi there,

    First of all, great work!!

    So I had been using your WoL page for a while but had an issue with my server and had to reinstall the whole thing, now I tried to reinstall the server and use your page once again but now I have the following error, with or without “https”:


    You don’t have permission to access / on this server.
    Server unable to read htaccess file, denying access to be safe

    Can you please help me out?

    1. YAY, I got it working back again.

      Turns out it was (as the error states) permissions on the files, all the certificate setup is fine.

      To solve it I used my ftp access and changed the permissions on the files and Voilá, it is working again :D

  5. Works ping?
    I am able to wake wakeonlan and mac command, but since the ‘web’ of my dns, always tells me that the system is awake when it is not, and there is no way to respond.
    I saw that the index.php does a ping -c 1 192.168.1.xx and I think the problem is it do not know how to interpret.

    if I run the same ping from the command line tells me 100% loss, which is logical because it is off

    What can happen?

    1. I’ve modified the index.php to do it works
      In the $pinginfo comparation with empty ($pinginfo == “” or != “”, i’ve to put this text “1 packets transmitted, 0 packets received, 100% packet loss”.

      Now, it works perfectly!

  6. Hi there.
    I made it work on a banana pi, great tool.

    One question: When I access the website from my cell phone, it nicely writes out step for step what it is doing, e.g. requesting computer state, Ping 1, Ping 2 etc. When I access it from the computer (Windows 8.1, Firefox and IE11) I see no change until the final result is there. Any ideas why?

  7. Just a quick thanks for your hard work and excellent instructions. Got my R Pi 3 this morning, and it’s a working WOL server tonight. Much appreciated.

  8. Hi i am having issues waking my PC, both locally and remotely.

    The WOL server will allow me to sleep the machine just not wake.

    If i try another WOL utility i am able to wake the machine locally.

    Any indication on what i could look at to troubleshoot?


  9. My thx for this Jeremy!

    I can now control everything from home, that’s just great!
    One question though. Is it possible to add an item to the wol page that instead of waking a pc, it just takes me to my router’s home page? I’d like to be able to remotely enable/disable my WLAN through it.


    1. Glad to hear you’re enjoying it! There’s a few ways you can do what you’re describing. Most routers have an option for enabling or disabling “remote” administration. Since you’re entering your network from the outside, the easiest option is to enable that (make sure you have a strong router admin password, and enable HTTPS!). It will usually give you the option to specify a port number. 8080 is a common default. Once you enable that, you could edit the WoL index html page to add a link to https://YOUREXTERNALIP:8080. If you are using a dynamic dns service, just replace YOUREXTERNALIP with that: Make sense?

      1. It works! Indeed, I enabled remote control to the router, set a port and voila! Adding the port to the end of its url, it takes me there instead of the wol page. Once again, many many thx Jeremy!

  10. I had some troubles with this, but not this software in particular. My setup: Raspberry Pi 3 with WiFi connected to router ( to, Windows 7 PC with WiFi connected to same router ( to Then, I have a crossover cable between Pi and PC ( to, respectively, both set static). When I accessed the web page, the status was correct (showing either asleep or awake). However, wake on LAN magic packets weren’t sending/weren’t waking up the PC.

    I tried running wakeonlan [MAC] directly, but this didn’t work. I then tried wakeonlan -i [MAC], and this didn’t work either.

    Then I tried installing etherwake because I saw some documentation suggested it might work on all Debian-related distros. etherwake [MAC] worked. I considered editing the index.php code to change to etherwake, but then I tried wakeonlan [MAC] which didn’t work, but then wakeonlan -i [MAC] DID work. I thought this was odd, suggesting that wakeonlan was quasi working.

    So I uninstalled etherwake and tried wakeonlan -i [MAC] instead of This worked! I changed the $COMPUTER_MAC to include this in the string prior to the MAC address. It WORKS!

  11. hi there,

    its works perfectly, thx! :-)

    i have a little problem. i have changed the document root to a different diretory. but it seems that the re-routing from HTTP to HTTPS stop working now. HTTPS only ist set to “true”

    thats from the 000-default.conf:

    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/XXXX/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/XXXX/privkey.pem

    DocumentRoot /var/www/html/wol

    AllowOverride AuthConfig FileInfo
    Order allow,deny
    allow from all
    Options -Indexes

    anyone a have idea?

    thx! :-)

  12. I finally figured it out :) Is it possibly somehow to shutdown the computer and turn it on again with this tool? The sleep is neat, just wondered if it was possible to shut it down completely and turn it on like the function Teamviewer has. Appreciate it a lot :)

  13. Ohh yeah and furthermore.. I just tried to access my dns from outside my LAN and it times out. There is no problems what so ever when Im on my LAN. What could be the problem here? Port forwarding?

  14. Ohh well actually managed to get it to work! But a few hours after I get the “Command Failed: Connection timed out after 5001 milliseconds”. What could be the problem now? Really was hoping for a stable solution with this WoL :(

  15. Hello Jeremy!

    One more question/request:

    I’ve bought one of those nice wifi controlled power sockets. After sniffing the packets its own custom android app sends for on/off, I managed to have the power socket switched with netcat. My question is, how can I add ie two links to the wol page which will execute the power on/off scripts I’ve made.

    Many thx!

    I thought I already had submitted this comment a few days back, but somehow my comment didn’t appear.

  16. Yesterday I managed to make it work.
    Today, this is what I get on sleep command: “Command Failed: Connection timed out after 5001 milliseconds”
    And on wake up, it simply doesn’t wake up. Any help?

  17. Great work!

    Helped me a lot because my router doesn’t support WOL or UDP broadcasting.

    Many thanks!

  18. This works brilliantly! I would love to change the array so that it reads from a CSV file instead, any opinions on how to do that? I have a network with around 40 devices I need to Wake up and it would be much easier if I could just keep an Excel spreadsheet with all the Names, Mac and IP of the devices & export to CSV when it changes. The code would then read the CSV instead of adding them all to the config file.


  19. I can get it to work from inside the network by going to my Pi IP of and it loads and can wake up my PC :D

    So I have port forwarded 440 from outside to 443 inside on TCP and UDP to my Pi and typing my externalip:440 refuses to connect

    for example xx.xx.xx.xx:440 wondering if anyone has a solution

    “This site can’t be reached

    [ExternalIPHere] refused to connect.”

    1. EDIT:
      I got it working by doing a few things, not sure which one it was
      1.upgraded the PC to be woken from windows 7 to windows 10
      2.changed how the Pi was connecting to my router, before it was via a USB wifi adapter now its ethernet
      3. added the port forwarding rule for 3389 that you had

      I should note that I expected to have to type [ExernalIP]:50 because I had port 50 forwarded to 80 but what actually loads the correct page is [ExernalIP]:80

      Very important right there

      You should specify for the noobs what port to access externally as my router just has two boxes saying start and end for the port numbers. I had no idea if when I forwarded 50 to 80 whether it does anything to the numbers between

  20. Hello guys. Im trying to start the SleepOnLan utility before I logon. The reason for this is because I run my plex as a service and that way I dont need to login first.

    I have tried to run SleepOnLan as a service aswell but when I boot up the PC without logging in and tries to shut it down again via the Remote Wake/Sleep-On-LAN I get the error: Command Failed: Connection timed out after 5001 milliseconds. That must be because the SleepOnLan utility isnt running. Any of you who might have stumbled across this? And perhaps found a solution?

    Best regards,

    1. I have asked this here before also but then there wasn’t any solution. I also have tried multiple solutions myself like running a task with the Task Manager and various scripts but non of them have worked. Since I have the EXACT same situation as Mathias, I also would be interested with a solution if there have appeared any in mean time.


      1. I have spent a lot of time trying to get sleep on lan to work also – no solution either (assuming you are using Windows). It seems impossible to start it before the Window login prompt.

        1. Im about to say Im glad I am not the only one with the problem, but Im not. This shouldnt be rocket science in any way, but I myself am not skilled enough to solve this cracker. What frustrates me is that I have several services running before login with requires a network connection – they run flawlessly.
          SleepOnLan utility just simply wont :/

          1. Don’t be frustrated. The fact that this awesome Wake/Sleep solution exists at all is a great thing and we all should be thankful to Jeremy that we can all use it FOR FREE!!! If he or who ever creates/finds a solution for our problems – Great, if not then we’ll just have to live with it or find a better way ow shutting down your PC. No-one has an obligation for developing it further.
            Simple alternative for for our problem – The times when I completely shut down my PC are very rare and if it’s the case I log on with TeamViewer and then the Sleep app works again.


          2. You are right Marko! It indeed is a wonderful tool completely free of charge. And I am not aiming my frustration at the creater more in a direction that my skills are not sufficient.

            I am just hoping that someone might find a solution for this at some point.

            Any of you tried something like NSSM – the Non-Sucking Service Manager, SRVANY or AlwaysUp?


    2. I personally dont use the sleep on lan much and just use teamviewer, it works from the login screen from boot. Ofc you have to login remotely

  21. Used your WOL for over a year until Router and Pi went out. Now, website says computer asleep, I enter the password, Pings 30 time in 1/2 sec and fails. The computer however DOES wake. Any idea why it isn’t recongnizing computer state and pings out?

    1. 30 times in half a sec? Did you mean minutes? Half a sec is clearly not enough time to let your computer to wake and respond to ping. I think I’ve set up the time to be 10 sec.


  22. Hi, worked great for me, with à bit struggling, as à newbie om the Raspberry. access to me nas from al over the world.
    Juist upgrades to THE new PIXEL-version and now it doesn’t work anymore. All the files are still there …. Anyone who knows this problem.

  23. Love this! Solved my plex sleeping problem! Question: can I edit the .css somewhere? I would love to make the landing page my own. I am simply not familiar enough with the pi yet to find it

    1. Sure. The index.php is located at (on RASPBIAN JESSIE WITH PIXEL) /var/www/html/ and the CSS in in the same tree “Bootstrap” folder.

  24. I am so salty. I wasted my time doing this installation to find out that you HAVE to use a dynamic DNS service to access the webpage. It makes absolutely no sense that I can’t just input the IP and port into a web browser and it work. I arrived at the part about router config and dyn DNS and my router doesn’t support any free dyn DNS service providers. I’m not going to pay 40 bucks a month for it, so I assumed I could just use the IP like I previously said, so I carried on with the installation. A long time later it was complete and I tested it. It didn’t work.


    Why set up an entire webserver just for one simple task? Why not just freaking SSH into the Pi with some PuTTY-equivalent app (I use “Connect Bot”) and run a one-lined script file.





    (insert the following into the file and write-out (replace with machine’s MAC))
    wakeonlan 00:00:00:00:00:00

    chmod +x

    THEN RUN THE SCRIPT (./ >>(of course the target machine has to have the appropriate settings to WOL)


    (I named each script the hostname of the machine it wakes to distinguish them from each other.)

    I figured this out and thought it so much easier and more worth my time with about the same amount of steps to actually wake a machine as would accessing a web browser and logging in would be. Don’t get me wrong, the web server is a neat idea, but it doesn’t suit me.

    1. For the record, you CAN just type your IP and port and it does work like that. The problem is that when your dynamic IP changes, you’ll have to know the new one. So how do you SSH to your Raspberry Pi with Dyn DNS? There’s should be no difference witch solution you use, relating to the IP type. If it doesn’t work then you did something wrong.

      Your router doesn’t have to support free Dyn DNS as long as it supports port forwarding. You can set up your Raspberry Pi to update your Dyn DNS service, like I have done. Just google it. And believe me, when you have it working, it takes exactly two clicks to wake or sleep your computer. I believe your solution takes way more and someone who doesn’t know about SSH and scripting it’s impossible to use.

  25. Hey, I just set this up on my raspberry PI in order to do wake on LAN of other computer’s on my network. This worked like a charm. The install was super easy and the instructions worked beautifully. Thanks for this!

  26. Quick question, and probably a silly one, however could this be exploited to gain entry behind a router? Basically is there any security risk here? From what I can tell the only risk is someone would be able to broadcast to my network and turn on some computers but thats it – Im no security expert however and wanted some opinions.

  27. Hi
    Thanks for going to the effort to help us newbies. I have installed as per your instructions but I can not get the index.php file to display. I made an info.php file to display the php information and this works but the index.php file will not display. Can you point me in a direction where I might find out why and how to fix.
    Thank you

  28. Hello, I’ve got it working for the past few years, with a SSD in windows 7. Now I have a new SSD with windows 10, and even when disabling fast boot, or activationg magic packet in the network card (well, doing same as with windows 7) it doesn’t wake up my comp. when i switch back to my windows 7 SSD, it works again… so the problem comes from windows 10. Any ideas ?

  29. Hi Jeremy,
    first af all merry christmas and….
    many thanks for this easy but powerful program. I’m using this on my Raspberry to start my NAS Server with the WOL command from the internet via a VPN tunnel – It works great since it’s not possible to do a WOL directly trough a VPN tunnel.

    However since you build up the solution using only one and the same password for all, I wonder if you can add the possibility to have several passwords for several people available to start several devices?

    Background: I want to give access to some friends of mine, but when we all use the same password including me, everyone can start everything available and I want to differ.
    For sure, I can ran your program twice behind i.e. a different web- or port adress to seperate but it would be great if the program has this opportunity.

    cheers, Dirk

    1. Hello there Dirk.

      Its 2 years sine you asked for this but Im just wondering if you every found a way to set several different passwords for different computeres?

      Cheers mate!

  30. Hey Jeremy,

    great tutorial. Now I have a question. Is there a possibility to use a password for every computer on its own? I don’t want to use the password of my server for my gaming pc.

  31. Have any of you had any luck setting this up with a PS4? To be able to wake up the PS4 through the pi?

  32. Hi, i don’t understand how to setup the wake on lan part, could you add explanations and screenshots for it too ?

    1. You just have to follow the instructions shown on the github-site. The link is provided at the end of this article. Just follow the instructions. It features screenshots and all the commands you need. Just copy and paste the given commands.

      1. I failed, wanted to say the sleep part :) the wake part works well but i don’t get it to sleep.

        1. Haha :D
          Ok. Well can’t help you with that, because I don’t need the sleep part for my setup. Sry.

  33. same problem here. Had to reinstall due to power outage. Now the sleep part does not work from the webpage. if i sent the command manually it does work so the sleep on lan util does work. problem must be in the pi part. Please help.

  34. I have an SSL cert that i use for my personal domain. So, when I go to i get the green lockbox in my web address bar. However, when I go to my pi and I have to enter a port ( my green lockbox goes away and chrome gives me the warning — I assume because it’s been set up with a self-signed cert.

    How do I go about using my SSL cert that I pay for with the wol server? I only seem to have a .crt and p7b file from my SSL Cert provider. I was hoping it would be as easy as swapping out the wol.csr, wol.key, and wol.crt files, but that doesnt’ seem to be the case.

  35. This is a perfect solution. Working perfect even for a relative unknown linux/raspberry user.
    I did the trick twice, as I upgraded to Raspian Stretch. However in Raspian Stretch some items are missing: php5 was not found . After googling I found a solution: to add some sources.

    If you simply add the following line to the end of /etc/apt/sources.list, you will have no problem retrieving php5 packages with apt-get:

    deb jessie main contrib non-free rpi

    found this at:

    But I assume that php7 could replace the php5-part (I’m unfamiliar with coding)

  36. Hi, i think the step by step- tutorial is no longer up-to date :-(

    i got some errors when trying to install php5-i think the package is no longer available-so the installation fails.

    Can you update the tutorial – at the moment your great Work seems to be useless ….

  37. Hi,

    I used to have this working on my Model b+ raspberry pi in fact it was the main reason I bought one was to run be able to wakeup my desktop PC from the Pi. Worked fine for years then my memory card died and my memory was fuzzy as to how I set it up.

    I downloaded the latest Noobs and found things went wrong during this setup command:-

    sudo apt-get install apache2 -y

    Instead to get it working again I needed to download an older Noobs. Clearly the new noobs is using newer apache built in which this doesn’t work?? I don’t know not a linux expert I just wanted the Pi to do what it used to.

    I used:-

    Then the instructions worked fine as they did before.

    To anyone trying to get this to work now the only way unless u are expert will be to get old noobs. Thought I’d write a response as often peple don’t when they answer something people are looking for answers for on the forums.

  38. Hi,

    Thanks for your thanks Mathias! Thought it might help people! Nothing worse than finding something to fulfil a need and then finding it might not work now!

    If there is any Raspberry Pi experts out there would love to know step by step how you get this to work on latest Noobs! But it 100% works on

    Best Regards


    1. Hi Gareth, it is just the tutorial that is not updated. You just need to replace php5 with php7.0. It has been explained here:

      I repeat the explanation by keem85: “Just noticed that php has been updated, and copy/paste the tutorial will not work. Every place it says “php5”, swap it with “php7.0″. It also affects the commands further down that points to php5 folder, that also has to be changed to the new location /php/7.0/xxx.”

      I tested it – it works.

      Best Regards,

  39. I’ve been using this for years, but was wondering if I could got to a specific URL and have it automatically send the WoL packet. This would be used for automation.

    For example, say my url was, currently I could send the url to set the drop down to the second computer. Is there any way I could do something like to automatically send the packet by just opening the webpage?

    1. What would be the point of doing this kind of automation on the web page? You could just use a random WoL app for that. There’s a ton of apps for all platforms that do just that.

      1. Basically so I can setup stuff like Google Home or Plex clients to remotely turn on my PC. I know there are other solutions, but I already have this setup and it has been working well for me, so If I could easily use it for this purpose as well it would be ideal.

  40. I’m not able to get the passphrase to work – I’ve got the SHA-256 passphrase put in the config.php file, but when I go into the HTTP site for testing I keep getting “invalid passphrase”. Target pc is running Win 10.

Leave a Reply to Jelle 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.