clew, your hosting company probably moved the database causing ‘localhost’ to fail. Ask them for the IP address of the DB server and see if that solves the problem.
allyanders, you might try asking your hosting company to look into it for you, particularly if you’re experiencing intermittent errors. On shared hosting it could be that someone else is running code that is locking/crashing the database. Or it could be something else entirely. Your hosting company is in the best position to figure that out.