Hi -
I managed to fix this on my own :)
I jumped into the postgressql logs and found some errors along the
lines of "no entry for ::1 for postgres in [some hba config
file]". I uncommented the line for IPv6 in this config file and
now it works. So it appears that the cause was totally unrelated to
what I thought; it's just that the OS can talk to itself either on
IPv4 or IPv6, and the times that it queried postgres on IPv4 it
worked, whereas querying postgres on IPv6 failed.
I'll post the exact steps after I've returned to the office tomorrow.