On a shared server with MySQL and Apache the MySQL server was periodically disallowing connections as there were already too many connections. The default is 150+1 so I added the following to /etc/my.cnf
max_connections=200
To increase the maximum number of connections to 200+1