Raspberry Pi Remote Wake-On-LAN Server


Build a Simple WOL Server

Build a Simple WOL Server

Update (7/15/2013): Added instructions for enabling use with Windows 8 (Which does not reply to ping requests by default)
Update (7/20/2013): Added ability to put Windows Computers to sleep using the Webapp
Update (12/15/2013): Added Ability to control multiple computers
Update (9/14/2015): Control can now be achieved over an encrypted (HTTPS) connection, and additional security improvements have been made.

I have a very power hungry desktop computer that I use for video editing and large file storage. When I’m travelling with my laptop, I obviously 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 below). 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…

When you’re done, here’s how this 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 this (note, you may get a security popup first, if you choose to use a self-signed certificate to enable HTTPS – this is described later):
    Remote WOL Wake-Up Screen
  3. Next, you’ll enter a passphrase that you’ve pre-allowed. 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 will send a “Wake Up” command to the network interface of the computer that you want to wake up. It will then ping that computer and display the results in real-time, so that you know when the computer has finished booting and is accessible. That screen looks like this:
    Remote WOL Feedback Screen
  4. Once you’ve received confirmation that the computer is alive, you can access it as you normally would, depending on what you’re doing (via SSH, FTP, or Windows Remote Desktop, for example).

For the purposes of the following explanation and tutorial, I’ll define a few terms:

  • Remote Computer: This is the “power-hungry” computer located on the same network as your Raspberry Pi. I’m assuming you are using a hardwired Ethernet connection, since Wake-On-LAN (WOL) does not work over Wi-Fi.
  • WOL Sever (Raspberry Pi): This is the low-power, always-on, micro server that will be running on the same network as the remote computer. You don’t have to use a Raspberry Pi; any low-power platform capable of serving up web pages, running PHP, and sending Wake-On-LAN magic packets will work fine.
  • Client: This is the computer, phone, or other web-connected device that will view the WOL control webpage.
  • Router: I assume you are using a home router with a fairly standard feature set, and that you have administrative access to it. It should support DHCP address reservations, NAT port forwarding, and ideally support for a dynamic DNS updating service (like DynDNS or NoIP).
  • Dynamic DNS Service: This is a service that handles redirecting a URL to your home’s dynamic IP address. Since most ISPs assign dynamic WAN IP addresses, you need to use a service like this to ensure you can maintain access to your home network, even when the externally-facing IP address changes.

Here’s what you need to do to get this working:

  1. Ensure that the remote computer supports Wake-On-Lan (WOL) functionality. You may need to boot into the BIOS and permit the computer to be woken up via the network interface. This will look different on nearly every BIOS. LifeHacker has a good tutorial showing how to enable WOL functionality.
  2. Setup your Raspberry Pi with a linux distribution if you haven’t already, and get it connected to your network. Adafruit has a great set of tutorials that can help you do the initial setup for your Raspberry Pi.
  3. Log into your Router’s administration panel (in most scenarios you can do this by visiting your Gateway IP from your browser). Find the status page and locate the listing of attached clients. Identify your Raspberry Pi and your computer by their hostnames, and copy down their MAC addresses, and IP addresses. In the screenshot below, the hostname of the computer I want to control is “PHOENIX” and the Pi’s hostname is, appropriately, “raspberrypi.” This will vary by router, but the listing will look something like this (Note: I blurred out some of my personal info):
    LAN Client LIsting
  4. Now, find the “DHCP Reservation” or “Static Leases” list in your router’s administration panel. You’ll configure your router to always assign your remote computer and the raspberry pi the same IP address every time they connect to the network. This ensures that you’ll be able to reliably forward data to them through the router. It will look something like this:
    Assigning Static Leases
  5. Next, find the port forwarding configuration screen in your router’s administration panel. You’ll want to route the HTTP port (TCP 80) and/or HTTPS port (TCP 443). Note, you only need to forward port 443 if you plan to enable SSL encryption following the steps below. These ports will be used to send data to the raspberry pi. You’ll also need to forward any remote service ports that you want to use to access the remote computer. Importantly, many ISPs will block incoming traffic on port 80 and or 443, the default HTTP(S) ports, to prevent customers from hosting websites from their residences. But, you’re smarter than they are! Simply route an arbitrary external port, to the internal port 80 or 443 on your Raspberry Pi. In the screenshot below, you can see that I am routing external port 5000 to internal port 80. This means that when you eventually access the WOL server, you’ll need to specify the port, like this: Route the appropriate port for whatever services you want to access on the remote computer. In the screenshot below, I’ve routed port 3389, which is what Window’s uses for Remote Desktop. If you wanted to access an SSH server or SFTP server running on the remote computer, you could additionally route port 22. You can find a listing of ports used by various services on wikipedia.
    Port Forwarding
  6. Next, you’ll want to sign up for a dynamic DNS updating service that your router supports. Different routers support different services. I chose to use DynDNS, since I’m grandfathered into their free account plan, and because my router supports it. Unfortunately, DynDNS no longer offers its free services, but does, and is supported by many routers. Sign up for a free account, and get a URL that looks something like this: NoIP even supports port 80 redirects, so you can configure your account to not require appending the non-standard port number to the end as described in the last step. Once you’ve got your dynamic DNS account, find the Dynamic DNS (DDNS) updating screen in your router’s administration panel, and enter your account info. Now, you’ll always be able to access your home network, without knowing the IP addresses, and the router will handle automatically updating where the URL directs when your dynamic IP changes!
  7. Now that your router is all set to handle everything, it’s time to get the Raspberry Pi setup. Access your Raspberry Pi over SSH and log in with the username (pi) and the password that you configured when you followed the setup tutorial linked from step 2. All the steps for how to configure your pi can be found in the README for this project’s GitHub Repo. Note that it includes optional steps for enabling SSL encryption. These additional security measures have been implemented by GitHub user felixrr. If you want to setup your WOL server to work over an encrypted connection, you need to ensure port 443 is forwarded, you need to follow the additional steps in the README, and you need to be aware that unsigned certificates will cause a warning in most browsers that will warn you about the certificate being unsigned (you can safely bypass these warnings).

Update (7/15/2013):

If the remote computer is Windows 8, you will need to change some settings to make it reply to ping requests (or else you won’t know when it has woken up). By default, Window 8 does not reply to pings. Follow these instructions to make it reply.

Update (7/20/2013):

I’ve added the ability to put the computer back to sleep using the mobile webapp. The new version of the code can still be found on GitHub. Follow the same instructions from above and in the README. For it to work, you’ll need to ensure that Curl is enabled for your PHP installation (you should have already done this when you ran “sudo apt-get install php5-curl”), and that your remote computer is running the Sleep-on-LAN application server:

Download the Sleep on LAN (v1.1 alt download link) software and run it on your windows computer. Set it to launch at boot so that it will always be ready to go.

Note, with this updated version of the webapp, it will now ping the computer to check if it’s awake or not to decide if it should present you with a “Wake Up” or “Put to Sleep” button on the interface.

Update (12/15/2013):

The app now includes a dropdown that allows you to pick a computer. The config file has been updated to include lists for computer names, IP addresses, and MAC addresses. 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).

Update (09/14/2015):

The Raspberry Pi WOL software now supports 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! Make sure you read and perform the additional steps in the README, and that you port forward the HTTPS port, and enable HTTPS enforcing in the config file. If you don’t want to use HTTPS, simply skip those steps, forward the HTTP port, and don’t enforce HTTPS in the config file (this remains the default option).

You’re done! Put the computer to sleep, visit the dynamic URL that you chose, and you should be presented with the screen that was shown earlier in the tutorial. When you input your passphrase, it will be compared with the hash by the PHP script. If it is approved, the Raspberry Pi will send a command to the remote machine to wake it up. The display will update in real time to show you when the machine has woken up and successfully joined the network. You can then access it using any program whose ports you’ve forwarded. Enjoy!

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. please help me out!! i am facing a lot of trouble in developing a remote desktop display for my raspberry pi.
    and am not able to update my raspberry pi..

  2. hello sir
    may you upload tutorials about how to start with raspberry pi…

  3. Your app is perfect! Thanks

    I can’t see what could be better…. or maybe to be able to wake up more than one device :-)

  4. Hello there,

    I followed all the steps as directed, but When I load the page I only receive a blank webpage, the page loads and the port forwarding is correct. I suspect it has to deal with the program not running correctly on my Pi. Any ideas?

    • You should enable PHP error printing by putting these lines at the top of your index.php file, in the < ?php ?> section:
      ini_set(‘display_errors’, ‘1’);

      That should help you figure out what’s wrong.

  5. Thank you very much for your work. I have been thinking about doing something like that for a long time. But due to a lack of time and the fact that I’m not that familiar with linux, webserver and php5, I never got around to actually doing it. But with your work I have a solid starting point and can build on that to make it my own (incl. more than one computer, choosing the kind of “shutdown” and especially using the GPIO to control a relay to cut off the power completely). And for a newbie like me it’s also a good starting point for adding environmental sensors.

    Keep up your good tutorials (I started with your Arduino tutorials :))!


    • Great! Be sure to publish any improvements you make that others might benefit from!

      • I will definitely do that. In the meantime maybe somebody reads this and thinks … “Well, it would be nice to have an Android app for that.” … In would be awesome to have a starting point there as well ;).

  6. I don’t get it. Why so complicated solution ? Why not simply ssh to router and run etherwake ? Rapberry PI is superfluos.

    • I wanted a dedicated interface for this, and I wanted it to be pretty, with feedback about the current state of the machine. This was mostly a learning exercise for me.

  7. Hi,
    This was an excellent article and me being new to RPi and linux i found this very interesting.
    I followed all the steps closely but when I go to the webpage, my passphrase is always denied.
    Any ideas on what could be the issue and how to fix it?

  8. This is an amazing article. I have a localised problem, is there anyway to exclude the $COMPUTER_LOCAL_IP from the config. My router seems to block any direct reference to an IP address. I can WOL my PC from an app on my iPad just using the MAC address. Would be grateful if you can help?

    • Weird. What router are you using? I don’t see how or why it would block direct references to an IP address. What happens if you want to set up file sharing on your network?

  9. This is brilliant. One question though if you don’t mind? I think due to the prescence of another index file (index.html), after I press wake up it returns to the “orignal” index page. Is there a way to repoint this reversion and for example rename index.php to wol.php and have the software acknowledge this?



    • Why not just delete the index.html file? You shouldn’t have two index files, even if they are different file types. If you are using index.html for something else, you can rename this file wol.php, and change the form action to point to wol.php instead of “/”

      • Hi. As you mention, I am using the index.html file for something else and could do with altering your index.php file really.
        Am I right in saying the reason when I press wakeup it returns to index.html is something in your code? Which would therefore require repointing to (eg) wol.php?
        I am a learner and so any help is much appreciated.

  10. All sorted. Thanks for your help.

  11. Can I get this working with openelec somehow?

  12. Hi Jeremy,

    I’m stuck with the passphrase. I created a passphrase used the hash calculator to create a hash for the passphrase and copied the hash to the config.php file.

    Restarted the webserver but still getting denied message.

    Any ideas?


  13. Hi Jeremy,

    Thanks for your fast response. Yes I’ve renamed the sample.

    You can check my config on the following url.


  14. Hi, thaaank you so much! Your stuff is awesome and you inspired me to build a raspberry pi and I’m going to make something awesome with it.. :)

  15. Hello!
    I have problems. I follow the manual and i have no errors in the installation-procedure but i doesnt see any homepage.

    What have i done?
    I also define on my router a portforwarding “port:5000” -> ip-adresse from pi -> to “port:80” (its the same procedure i have made for my ipcam and this portforwarding works – i check this also).
    I enter in my win7-pc in the inet-explorer my “dyndns-adress:5000” but i doesn’t see anything?!

    Is it necessary to start or restart the wake-on-lan-server? and how does this work?
    What are the default ports in this example? 5000? 3389? 80? 7760?

    I hope you can help me!

  16. Hi Jeremy,

    Which OS distribution you are using on your Raspberry PI?


  17. Thanks for your response and writing this blog Jeremy!

  18. Hey Jeremy have you any tutorials about doing this with the arduino and ethernet shield. Looking for a good full tutorial but can,t find one online. Keep up the good work very enjoyable.

  19. On the firt page i always have the error

    Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in /var/www/index.php on line 18

    Any reply was really appreciate.

    Thanks !!!!

    • Hmmm, that means output buffering isn’t working (this is what allows the page to update as it loads with ping updates).

      try adding the following line to an .htaccess file in the same directory:
      php_value output_buffering “0”

  20. How can I specify the port I want to use? And how do I start or stop the service/run it on start up?

  21. Hi
    I need a bit of help on this!
    Followed all the instructions with no error but when trying to access the start page I get “The page can’t be displayed”.
    Error reporting is enabled in the index.php file (was enabled by default) but I don’t see any errors.
    To check if the webserver and PHP were installed OK I created a simple index.php file which I put in the www directory (temporarily moved the one that came with WOL). This says ‘Welcome …’ and I can access this both from local IP and from my dynamic dyns URL.
    So webserver and php seem to be running.
    Have tried to totally reinstall but still no success.

    Any suggestions greatly appreciated – would love to get this running!

  22. Found my error!
    Managed to find the location of the error log /var/log/apache2/error.log and saw that it was the hash in the config.php file that was causing the problem.
    First I had forgotten to put it in ” ” and then when I did it didn’t become active until I rebooted.
    Working well now – thanks for a great tool!

  23. I too would like to see this done on an arduino uno step by step if you could. Thanks Shane

  24. Hmm it seems to work on my LAN, but not outside my LAN.

    I als use the PI al proxy true port 1194 (as many tutorials) so normally i need go to my publicip:1194 ?

  25. can you give a good example of what the config file should look like?

    ie should the mac and ip addresses be in double quotes? single quotes? no quotes?

    Thank you

  26. HI,

    Thanks for this nice solution to remote wake/sleep my server :)

    I installed the php on my synology. The webpage is working well.
    But when i go to the page the webapp tells me the computer is allready awake while its powered off.

    What could be wrong?


    • Sleep-On-Lan works but the webapp thinks its still awake.

      It tells the sleep command succeeded.
      Then pings 10times > Still Awake

      Then i get an FAILED. But my server is a sleep :)

      I think my NIC stays alive. Can this be?

      • That’s what it seems like. If it says it is awake when it is off, then the ping must be getting a reply, which means the NIC is fully awake. What OS is the server? What kind of computer? You may be able to adjust the sleep settings in the Bios (try lowering it from S1 to S3, for instance).

  27. Jeremy,

    Os is server 2008 r2 on a hp dc 7900 usdt.
    I cant find anything in the bios what could keep the nic awake.

    Thanks 4 your help m8 :)

  28. Jeremy,

    I did some troubleshooting today and i found out that de webapp is saying the pc is awake even when the pc has no power source.

    Any idea?

    • Ok, well the Raspberry Pi is just running a ping command and checking for a reply. SSH in the the Raspberry Pi, and try pinging the computer’s IP address directly to see what happens. Are you sure you’ve se the right IP for the computer you are trying to wake up?

  29. Jeremy,

    Start with windows doesnt work :(

  30. I’ve been looking for some way to do this literally for years. Some things I noticed though are that with my connection the pings happen so fast that I have to do 100 to be sure the computer reports back that it is up. It would be nice if their were either a delay set between pings, or better, if the pings were just posted over each other (old one erased) so that only one line of text would show up no matter how many pings occurred. I usually get in the 80’s.

    For anyone wanting to wake up more than one computer, the trick is to make several copies of the files on your raspberry pi web server in separate folders and set each one to wake a different computer. It looks like you should be able to put the bootstrap folder one level up to have less duplication if you specify it’s location in thee configuration file. Would be nice though if one of the variables in the configuration file set a title so we could mark which computer was being woken up.

  31. Hey Jeremy,
    Fair play you’ve created a great project.

    I’m just wondering , I’ve 3 different devices and wondering if its possible to add a list to be able to choose which device to power on?


  32. “find the Dynamic DNS (DDNS) updating screen in your router’s administration panel, and enter your account info”

    what do you do if your router doesnt support DDNS? Can you use the Linux no-ip DUC on the RPI?

  33. Thanks for the mention. Love the tool :)

  34. Hello,

    in my var/www directory is still another webinterface. How can I change the Port to a random one? I don’t need to get from net via portforwarding to the Wake on Lan page. My iPhone is connected via VPN, so i want to get via Browser (192.168.x.x/wakeonlan.php) to the landing page, for example.

    Thank You

    Best regards

  35. You don’t need to change the port. Just change the file name from index to something else, like wol.php. The script should still work just fine (this was fixed in a commit about a month ago).

  36. Hi Jeremy,

    thank you very much, i have not seen this commit.
    Very nice tool.


  37. Hello Jeremy,

    nice tool :)! Is it possible to make a cronjob for waking up my Windows pc every week at 02:00 o’ clock pm to make a Backup?



  38. Hi,

    i thought I can impelment the wake up job into my raspberry pi cron scheduler and when my client is up acronis makes a backup (with a specific schedule) every week for example. Windows task scheduler is not able to start a pc?

    Best regards

    • Sure, you should be able to do that. Use “crontab -e” to edit the cronjob on your pi. add a line with the desired weekly time, and run the “wakeonlan” command with the right arguments.

  39. When i git clone it asks for a user password??

  40. Hi Jeremy, first of all excellent work! I installed your wol-server on a raspberry pi using the arm version of arch linux and got it working, with slightly different package names of course. When I start the wol script my server wakes up but isn’t detected as awake. I’m getting 10x still down, so something with the pings isnt working yet. When I ssh into the pi and do a “ping -c 1 computerip” I get this reply:
    PING ( 56(84) bytes of data.
    64 bytes from icmp_seq=1 ttl=64 time=0.451 ms

    — ping statistics —
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.451/0.451/0.451/0.000 ms

    Any ideas how to solve this?
    Thanks in advance!!

    • Hmm…. Try confirming that the exec command from PHP is working okay by adding “echo $pinginfo;” after the following line. If nothing shows up, then exec must be failing, and it may have something to do with permissions differences on arch linux.

      $pinginfo = exec(“ping -c 1 ” . $COMPUTER_LOCAL_IP[$selectedComputer]);

  41. Nevermind, figured it out. I replaced the if condition with (strpos($pinginfo,’64 bytes’) == true).

  42. Hi There,

    I made it through your exellent guis, but having trouble getting my computer to sleep. I got the following Error: Fatal error: Call to undefined function curl_init() in /var/www/index.php on line 199

    Could you help me out?

    Thanks a lot!


  43. hi

    It’s great solution. It’s possible to run it on ngnix instead of apache?


  44. Pingback: Wake on Lan Web | Mi Libreta Moleskine de Informática

  45. Hi, I am really grateful for your awesome work on this.

    It just works flawlessly, and the tutorial was easy to follow.

    Since I only want to wake (not put to sleep) my PC, is there any way to easily get rid of the Sleep! Button? I messed with the PHP so it doesnt do anything anymore, but the Button remained in place. Also: Is there a way to remove the dropdown menu, since I only use it for my main PC?

    These are more css and html related questions, but if you could help me with what lines to modify I would be so happy :)

    Thanks again!

  46. Pingback: Telenet: WOL via WAN

  47. Hi and thank you for such a nice tutorial.

    I have a problem, maybe you could help?
    My ISP blocks all of the incoming traffic below 1024. But I think your solution listens to port 80? So I’m stuck again by my ISP…

    Is there a way to change that port number so I can access the Pi over WAN?

    Thanks anyway!

  48. Very nice app for the pi, works perfectly!

  49. Hi Jeremy,
    I’m loving what you’ve done, and the tutorial is awesome I had it up and running really quickly. While I have it working, I still don’t have the full functionality I need.

    I’ll explain my setup – my house uses WiFi for all connections to the router, this complicated any WoL attempts, requiring other ethernet connected hardware. That’s where raspberry Pi comes in to the rescue. I had a my Pi connected to the wifi network, with a direct ethernet connection to the laptop. This worked sometimes, but even with fixed IP on both ends it wasn’t reliable, especially after a few hours off period. Current set up is with a second router/switch. The raspberry pi remains connected to the modem router by WiFi, it is then also connected to the second switch by ethernet. The laptop is also connected by ethernet to the second switch.

    This setup allows me to wake the laptop wirelessly, from my phone. I have a tasker task which switches to the second network and sends the WoL packet. My problem is that I can’t make your WoL Server send the command onto the second network. Sub domains are 192.168.0.XXX and 192.168.254.XXX for networks 1 and 2 respectively. Is it possible for your server to run off one network interface, but send the WoL command out on another?

    Many thanks

    • Hmmmm….. That may be a bit tricky. The web server is running on only one of the network interfaces. What happens if you run the wakeonlan linux app directly from the shell; does that work?

  50. I keep getting this error when I want to sleep it.

    Fatal error: Call to undefined function curl_init() in /var/www/index.php on line 199

Leave a Reply

Required fields are marked *.