WiFi Error: "Failed to connect to network" Intermittently, when I try to connect to a WiFi network, I get the following error message as a toast message:

Failed to connect to network

The message pops up immediately upon attempting to connect, so clearly it isn't trying and failing. I haven't found any mention of an error in the logs. The affected networks are ones that I've previously connected to with no change in settings.
How can I figure out what the problem is?
I've got a rooted Galaxy Nexus running Android 4.1.1 and the stock ROM. This question is related to another question that I posted earlier, but this one is more about how to find the source of a particular error message, so its focus is different.
Additional Details
Here are some more details based on the comments:

I've observed this on my home and work networks. One is identified as WPA2 PSK and the other is identified as WPA/WPA2 PSK.

I haven't powered off the phone as described in the troubleshooting guide mentioned in the comments. However, I have rebooted to no avail (using the reboot command that's available on rooted phones).

Forgetting the network and re-adding it has no effect. In fact, if I forget the network I can no longer successfully re-add it.

The wireless password hasn't changed.

There's no proxy configured when I'm on wireless. However, I run Onavo Extend when I'm on a data connection. Disabling it has no effect.

I've switched from DHCP to static IP addresses. Doing so reduced the frequency of problems and seems to have eliminated my earlier issue where wifi would be randomly dropped.

Wifi sleep is set to &quot;Only when plugged in.&quot; I don't think it's relevant because my issue is establishing a connection in the first place (such as when I arrive at home or at work), not maintaining one.


Note that despite all these troubleshooting steps,my initial goal is to find an actual error message or log entry that gives useful information about the problem.
Do you have custom recovery installed? I have had this problem twice on a Galaxy S2, and what fixed it for me every time was running a permissions fix from recovery mode.

If that doesn't work, try deleting your WiFi config file. Not sure what it is on the Nexus, but I'm guessing it'll be something along the lines of /data/misc/wifi/wpa_supplicant.conf or /data/misc/wifi/wpa.conf. Obviously you should make backups before deleting anything. Note that you'll lose all your WiFi settings if you do this.