I currently have my pi successfully connected to my wifi. The thing is that our router turns off every night which the pi doesn't seem to like since it just refuses to connect to it after that. The only solution I know is to restart it every morning.

Is there a way to make it automatically connect it to the wifi again so that I don't have to restart it manually every time?

The connection is setup via the wpa_supplicant.conf and it runs in headless mode in case it makes any different.


A script that checks the WiFi connection and then tries to reconnect.

This article explains in detail:


Edited to add critical information from the site linked. Script:


# The IP for the server you wish to ping ( is a public Google DNS server)

# Only send two pings, sending output to /dev/null
ping -c2 ${SERVER} > /dev/null

# If the return code from ping ($?) is not 0 (meaning there was an error)
if [ $? != 0 ]
    # Restart the wireless interface
    ifdown --force wlan0
    ifup wlan0

add this line to /etc/crontab:

*/5 *   * * *   root    /usr/local/bin/wifi_rebooter.sh
  • 2
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. As you may have noticed on other answers we try to strongly encourage to extend answers so that they stand on their own with the link as reference only. – Ghanima Aug 24 '17 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.