The server you're hosted on is most likely hitting the mysql connection limit. When that happens, MySQL often denies access/connection requests which result in that error.

The fact that it works at times means your configuration settings are just fine. Now the cause is either what I mentioned above, and if not that, then it's quite likely that the main server's MySQL is taken down for maintenance every so often. Although, for the life of me, I would not be able to figure out why they would do that. MySQL needs little maintenance.

You should talk to your host first, about this issue. If they are unable to help you, switch hosts.