I got the same Exception with PostgreSQL 8.4, but I connect to a local db on the same host. The reason was the connection, which was not valid any more and so I needed to open it again.
There is a ticket on postgresql.org which has a related topic. Their answer is pretty similar, by just catching the exception and re-open the connection