I have Raspbian running on my Raspberry Pi, and I want to have a browser appear when it starts up. I am able to open a Midori window to the right page on start up, but my problem is that I receive a "cannot resolve host name" error, such like I would get if I was not connected to the internet. I followed the instructions listed on http://www.niteoweb.com/blog/raspberry-pi-boot-to-browser which were to enter in the command line:

$ sudo nano /etc/xdg/lxsession/LXDE/autostart

Comment everything and add the following lines:

@xset s off
@xset -dpms
@xset s noblank
@midori -e Fullscreen -a http://google.com

This process does open a Midori window on startup, but with the error mentioned above. If the page is refreshed then it works, but I want to be able to bring up a url without having a mouse or keyboard. I read that at the beginning of startup, internet may not be connected yet, so I created a bash script that delayed the process by twenty seconds before opening the Midori window. This did no work either, the same error persisted. I have also tried the process with chromium, to no avail as well.

4 Answers 4


On my Pi I have a script that checks if I have an IP address before it does anything else:


import socket
from time import sleep

def checknetwork():
    ip = False
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('google.com', 0))
        ip = s.getsockname()[0]
    except socket.error:
        return False
        return ip

def main():
    x = checknetwork()
    while x == False:
        print "Checking network ..."
        x = checknetwork()

This just tries to open a socket to some known address and fails until it can actually get a connection. Make it executable with:

chmod +x ip.py

You then need to add this to bootup by adding it to /etc/rc.local:

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

/usr/bin/python /directory/where/you/put/ip.py

exit 0

Hope that helps


I solved this problem by not entering my wireless network key but instead using the option of push button on Ap router. Connected straight away with no more problems even using wireless keyboard and mouse (via powered USB hub)

  • How does this relate to the OP's question?
    – jasonwryan
    Oct 15, 2013 at 0:11

Use ifconfig to detect ip address, and wait until you have an ip address (that is, $? == 0) (this assumes ipv4),

$ /sbin/ifconfig |grep "inet " |grep -v ""
inet  netmask  broadcast
$ echo $?

that is,

while [ 1 ]; do
    ip=`/sbin/ifconfig |grep -v "" |grep "inet "`
    [[ $? == 0 ]] && break;
    echo "wait for ip"; sleep 1;
echo "got ip: $ip"


@lxpanel --profile LXDE

@pcmanfm --desktop --profile LXDE

@xscreensaver -no-splash

@midori  --inactivity-reset=60 -e Fullscreen -a http://www.google.com

works for me

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .