About the $CFG->db* settings: The only thing I notice is the 'dbcollation' => 'utf8mb4_czech_ci'. utf8mb4_unicode_ci is advised. But that can not be the cause of sporadic errors. Still worth checking the Administration via command line#Converting character set and collation. Your config.php file looks like a shared hosting. Hope, you have CLI access.
5xx errors come from the web server - most of the time. So it is logical that Moodle doesn't log them. You need to search the web server error logs.
About the "resources" I linked: They happen to be called "Before you post.. Read this.."!
About the "resources" I linked: They happen to be called "Before you post.. Read this.."!