There are a number of possibilities, including that the path between your carrier's entry to the internet and the server you're trying to get to is bad, your carrier lost internet connection for a moment, your carrier's DNS server went down, etc., etc. Wifi enters the internet at your ISP's entry point, uses its DNS servers, etc., so it's seeing the internet differently.
If there's a pattern to it, it may be possible to figure out what's happening, but if it's random, it would probably take longer to find the problem than it's going to last.
When you get that problem message, do you try again right away - if the path was slow for a moment, and the connection attempt timed out, that could re-establish it.