Costa, I don't know what the source of the problem might be but may I recommend DBI's method "ping" after the connect to see if the connection is alive?
This basically does a "SELECT 1" on the connection you call it on and is generally a good way of testing since it less likely to fail due to, say, permissioning issues on the database that would prevent data from being returned even though they are there.
e.g.
unless ($dbh->ping()) {
print STDERR "Oops, we definitely have a problem\n";
}
Regards...