Uncaught PDOException

SQLSTATE[HY000] [2002] Connection refused

/home/u27272p186759/domains/camelcraft.nl/public_html/core/classes/Database/DB.php

https://www.camelcraft.nl/profile/diamondgear1/
/home/u27272p186759/domains/camelcraft.nl/public_html/core/classes/Database/DB.php
        string $username,
        string $password,
        int $port,
        ?string $force_charset,
        ?string $force_collation,
        string $prefix
    ) {
        $this->_force_charset = $force_charset;
        $this->_force_collation = $force_collation;
        $this->_prefix = $prefix;

        $connection_string = 'mysql:host=' . $host . ';port=' . $port . ';dbname=' . $database;
        if ($force_charset) {
            $connection_string .= ';charset=' . $force_charset;
        }
        $this->_pdo = new PDO(
            $connection_string,
            $username,
            $password,
            [
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            ]
        );

        $this->_query_recorder = QueryRecorder::getInstance();
    }

    public static function getCustomInstance(
        string $host,
        string $database,
        string $username,
        string $password,
        int $port = 3306,
        ?string $force_charset = null,
        ?string $force_collation = null,
        string $prefix = 'nl2_'
    ): DB {
        return new DB(
            $host,
            $database,
            $username,
/home/u27272p186759/domains/camelcraft.nl/public_html/core/classes/Database/DB.php
            $password,
            [
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            ]
        );

        $this->_query_recorder = QueryRecorder::getInstance();
    }

    public static function getCustomInstance(
        string $host,
        string $database,
        string $username,
        string $password,
        int $port = 3306,
        ?string $force_charset = null,
        ?string $force_collation = null,
        string $prefix = 'nl2_'
    ): DB {
        return new DB(
            $host,
            $database,
            $username,
            $password,
            $port,
            $force_charset,
            $force_collation,
            $prefix
        );
    }

    public static function getInstance(): DB {
        if (self::$_instance) {
            return self::$_instance;
        }

        if (Config::get('mysql.initialise_charset')) {
            $force_charset = Config::get('mysql.charset') ?: 'utf8mb4';
        } else {
            $force_charset = null;
        }
/home/u27272p186759/domains/camelcraft.nl/public_html/core/classes/Database/DB.php

        if (Config::get('mysql.initialise_charset')) {
            $force_charset = Config::get('mysql.charset') ?: 'utf8mb4';
        } else {
            $force_charset = null;
        }

        if (Config::get('mysql.initialise_collation')) {
            $force_collation = Config::get('mysql.collation') ?: 'utf8mb4_unicode_ci';
        } else {
            $force_collation = null;
        }

        return self::$_instance = self::getCustomInstance(
            Config::get('mysql.host'),
            Config::get('mysql.db'),
            Config::get('mysql.username'),
            Config::get('mysql.password'),
            Config::get('mysql.port'),
            $force_charset,
            $force_collation
        );
    }

    /**
     * Get the underlying PDO instance.
     *
     * @return PDO The PDO instance.
     */
    public function getPDO(): PDO {
        return $this->_pdo;
    }

    /**
     * Begin a MySQL transaction
     */
    public function beginTransaction(): void {
        $this->_pdo->beginTransaction();
    }

    /**
/home/u27272p186759/domains/camelcraft.nl/public_html/core/classes/Database/PhinxAdapter.php
     * Checks the number of existing migration files compared to executed migrations in the database.
     * Alternatively we could check the output of a Phinx command, but that takes ~8x as long to execute.
     *
     * @throws RuntimeException If these numbers don't match.
     */
    public static function ensureUpToDate(): void {
        $migration_files = array_map(
            static function ($file_name) {
                [$version, $migration_name] = explode('_', $file_name, 2);
                $migration_name = str_replace(['.php', '_'], '', ucwords($migration_name, '_'));
                return $version . '_' . $migration_name;
            },
            array_filter(scandir(__DIR__ . '/../../migrations'), static function ($file_name) {
                // Pattern that matches Phinx migration file names (eg: 20230403000000_create_stroopwafel_table.php)
                return preg_match('/^\d{14}_\w+\.php$/', $file_name);
            }),
        );

        $migration_database_entries = array_map(static function ($row) {
            return $row->version . '_' . $row->migration_name;
        }, DB::getInstance()->query('SELECT version, migration_name FROM nl2_phinxlog')->results());

        $missing = array_diff($migration_files, $migration_database_entries);
        $extra = array_diff($migration_database_entries, $migration_files);

        // Likely a pull from the repo dev branch or migrations
        // weren't run during an upgrade script.
        if (($missing_count = count($missing)) > 0) {
            echo "There are $missing_count migrations files which have not been executed:" . '<br>';
            foreach ($missing as $missing_migration) {
                echo " - $missing_migration" . '<br>';
            }
        }

        // Something went wonky, either they've deleted migration files,
        // or they've added stuff to the nl2_phinxlog table.
        if (($extra_count = count($extra)) > 0) {
            if ($missing_count > 0) {
                echo '<br>';
            }
            echo "There are $extra_count executed migrations which do not have migration files associated:" . '<br>';
/home/u27272p186759/domains/camelcraft.nl/public_html/core/init.php
    if (Config::get('core.force_www')) {
        define('FORCE_WWW', true);
    }

    $host = HttpUtils::getHeader('Host');
    // Only check force HTTPS and force www. when Host header is set
    // These options don't make sense when making requests to IP addresses anyway
    if ($host !== null) {
        if (defined('FORCE_SSL') && HttpUtils::getProtocol() === 'http') {
            if (defined('FORCE_WWW') && !str_contains($host, 'www.')) {
                Redirect::to('https://www.' . $host . $_SERVER['REQUEST_URI']);
            } else {
                Redirect::to('https://' . $host . $_SERVER['REQUEST_URI']);
            }
        } else if (defined('FORCE_WWW') && !str_contains($host, 'www.')) {
            Redirect::to(HttpUtils::getProtocol() . '://www.' . $host . $_SERVER['REQUEST_URI']);
        }
    }

    // Ensure database is up-to-date
    PhinxAdapter::ensureUpToDate();

    // Error reporting
    if (!defined('DEBUGGING')) {
        if (Util::getSetting('error_reporting') === '1') {
            ini_set('display_startup_errors', 1);
            ini_set('display_errors', 1);
            error_reporting(-1);
            define('DEBUGGING', 1);
        } else {
            // Disable by default
            error_reporting(0);
            ini_set('display_errors', 0);
        }
    }

    /** @var Smarty $smarty */
    $smarty = $container->get('Smarty');

    if ((defined('DEBUGGING') && DEBUGGING) && class_exists('DebugBar\DebugBar')) {
        define('PHPDEBUGBAR', true);
/home/u27272p186759/domains/camelcraft.nl/public_html/index.php

if (!ini_get('upload_tmp_dir')) {
    $tmp_dir = sys_get_temp_dir();
} else {
    $tmp_dir = ini_get('upload_tmp_dir');
}

if (HttpUtils::getProtocol() === 'https') {
    ini_set('session.cookie_secure', 'On');
}

ini_set('session.cookie_httponly', 1);
ini_set('open_basedir', ROOT_PATH . PATH_SEPARATOR . $tmp_dir . PATH_SEPARATOR . '/proc/stat');

// Get the directory the user is trying to access
$directory = $_SERVER['REQUEST_URI'];
$directories = explode('/', $directory);
$lim = count($directories);

// Start initialising the page
require(ROOT_PATH . '/core/init.php');

// Get page to load from URL
if (!isset($_GET['route']) || $_GET['route'] == '/') {
    if (((!isset($_GET['route']) || ($_GET['route'] != '/')) && count($directories) > 1)) {
        require(ROOT_PATH . '/404.php');
    } else {
        // Homepage
        $pages->setActivePage($pages->getPageByURL('/'));
        require(ROOT_PATH . '/modules/Core/pages/index.php');
    }
    die();
}

$route = rtrim(strtok($_GET['route'], '?'), '/');

$all_pages = $pages->returnPages();

if (array_key_exists($route, $all_pages)) {
    $pages->setActivePage($all_pages[$route]);
    if (isset($all_pages[$route]['custom'])) {