![]() |
Main connection [MySQLi]: Connection refused - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Main connection [MySQLi]: Connection refused (/showthread.php?tid=80507) |
Main connection [MySQLi]: Connection refused - mrbryo - 11-09-2021 Hello, I've setup a docker with: php:7.4.24-apache, mariadb:10.3.27. The routing, controller and views all are working because I can see the results. When I try to connect to the database I get "Main connection [MySQLi]: Connection refused". I am able to connect to the database from the MariaDB docker CLI and a desktop application called TablePlus. After all the googling I will attempt to answer all the same questions people seem to ask. Not saying I've caught them all but these are the most common I've seen.
I'm a noob with docker so there is probably something I've missed...yet everything I've read indicates it is setup correctly. Think I might installed mysqladmin to see if it can connect to rule out connectivity with in the container. Here is my .env file: Code: database.default.hostname = '127.0.0.1' charset and DBCollat are the same value I used in the docker config for MariaDB. Here is the code for calling the DB: PHP Code: // initialize database class PHP Code: echo "Connected successfully"; Pretty sure it doesn't get past the first line. I have not modified my Database.php file in the Config folder. I'm at a loss on what to check next. Thank you for your time and support. RE: Main connection [MySQLi]: Connection refused - mrbryo - 11-09-2021 OK it was my hostname in the .env file. The way I have docker setup I gave MariaDB a "name" called "friends-db". Once I used that as the hostname it connected. Hopefully, always find the solution after you ask for help...anyone hopefully this helps someone out there! Also resolved issue with phpmyadmin connecting. |