Yes, Moodle has some maximum PHP versions as well as minimum. This table shows some of them, Moodle 3.4 isn't listed but 3.5 is shown as working with up to PHP 7.2.
If you're getting "Database connection failed" after changing PHP versions the new PHP version may be missing the extension containing the database driver, e.g. php-mysqlnd for MySQL/MariaDB, php-pgsql for PostgreSQL, or php-sqlsrv for SQL Server.
"Literally nothing changed, except PHP Versions" – well presumably the Moodle server's IP address has changed too, it's possible there's a restriction with the database user ($CFG->dbname in config.php) or a firewall rule that's blocking the connection from the Moodle server to the database server.
If you enable debugging by adding the following lines to config.php hopefully you'll get some more details about the problem:
@error_reporting(E_ALL | E_STRICT);
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;