This can sometimes happen when starting up or waking from sleep, as it can take a few seconds to re-establish the Wi-Fi connection.
-Which model Mac?
-Which version of OS X/macOS?
-Do you have a browser like Sarai or Google Chrome launch at startup or already open when waking from sleep? If so, does the error message automatically disappear and the web page load after 5-10 seconds?