It may also be that you have 2 network connections, for example ethernet and wifi, that ethernet is the default route but is down, and so that it fails although there are another connection that is working.