Houden Posted November 15, 2022 Share Posted November 15, 2022 I've been looking to get into using Doctrine for one of my projects these past couple of days and while on my localhost everything has been working perfectly fine so far I've had trouble even getting the application to run once I uploaded the things to the server today. Accessing my testpage gives me the following error message which obviously suggests that something's going wrong when I'm trying to connect to the database. RedisException Object ( [message:protected] => Connection refused [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line:protected] => 194 [trace:Exception:private] => Array ( [0] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line] => 194 [function] => connect [class] => Redis [type] => -> ) [1] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line] => 148 [function] => createCacheInstance [class] => Doctrine\ORM\ORMSetup [type] => :: ) [2] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line] => 42 [function] => createConfiguration [class] => Doctrine\ORM\ORMSetup [type] => :: ) [3] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/config/Database.php [line] => 28 [function] => createAnnotationMetadataConfiguration [class] => Doctrine\ORM\ORMSetup [type] => :: ) [4] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/config/Database.php [line] => 20 [function] => createEntityManager [class] => Database [type] => -> ) [5] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/entity/Dungeon.php [line] => 69 [function] => __construct [class] => Database [type] => -> ) [6] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/endpoints/get/dungeon.php [line] => 6 [function] => __construct [class] => Dungeon [type] => -> ) ) [previous:Exception:private] => ) The part of my database class that handles the initial connection and is thus, most likely, at fault for the error looks as follows /* Dev Env public $params = [ 'host' => 'localhost', 'user' => 'root', 'password' => 'myPass', 'dbname' => 'dbzt', 'driver' => 'pdo_mysql' ]; */ /* Prod Env */ public $params = [ 'host' => 'localhost', 'user' => 'devadmin', 'password' => 'myPass', 'dbname' => 'dbztdev', 'driver' => 'pdo_mysql' ]; private $entityManager; public function __construct() { $this->createEntityManager(); } public function createEntityManager() { try { $this->entityManager = EntityManager::create($this->params, ORM\ORMSetup::createAnnotationMetadataConfiguration([__DIR__.'/../entity'])); } catch (Exception $e) { print_r($e); } } Running this on localhost with the Dev Params enabled instead of the Prod ones runs perfectly but as soon as I make the switch I get this weird problem. I've also tried using the 'url' parameter lined out in the Doctrine docs instead, leading to the same result, same with trying to add an explicit port to the params in case something was wrong there. What are some other things I could try to troubleshoot in this situation? Quote Link to comment https://forums.phpfreaks.com/topic/315544-problems-connecting-to-a-database-via-doctrine-on-server-vs-localhost/ Share on other sites More sharing options...
maxxd Posted November 15, 2022 Share Posted November 15, 2022 That's a Redis exception, not a PDO exception. Quote Link to comment https://forums.phpfreaks.com/topic/315544-problems-connecting-to-a-database-via-doctrine-on-server-vs-localhost/#findComment-1602648 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.