Welcome Guest, Not a member yet? Register   Sign In
CL4 Connecting to a Remote AWS Database
#1

(This post was last modified: 04-30-2024, 08:59 PM by kenjis.)

CL 4.5.1 running on AWS Ubuntu with Plesk.

I am trying to connect to a database on our AWS test server from our AWS production server. 

When I connect to a local db on production it works but the remote (test) db connection throws a 500 error, but I can't see what the exact error is. 

Port 3306 is open on both AWS instances. 

I have set allow access from all sources. 

I have tried both the IP address and domain name in the hostname property.

Any advice?


PHP Code:
    public array $default = [
        'DSN'      => '',
        'hostname' => '54.200.xxx.xxx',
        'username' => 'test',
        'password' => 'password123',
        'database' => 'test',
        'DBDriver' => 'MySQLi',
        'DBPrefix' => '',
        'pConnect' => false,
        'DBDebug'  => true,
        'charset'  => 'utf8',
        'DBCollat' => 'utf8_general_ci',
        'swapPre'  => '',
        'encrypt'  => false,
        'compress' => false,
        'strictOn' => false,
        'failover' => [],
        'port'    => 3306,
    ]; 

The Error

Uncaught Error.
{
    "title": "CodeIgniter\\Database\\Exceptions\\DatabaseException",
    "type": "CodeIgniter\\Database\\Exceptions\\DatabaseException",
    "code": 500,
    "message": "Unable to connect to the database.\nMain connection [MySQLi]: Connection refused",
    "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/system/Database/BaseConnection.php",
    "line": 428,
    "trace": [
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/system/Database/BaseConnection.php",
            "line": 575,
            "function": "initialize",
            "class": "CodeIgniter\\Database\\BaseConnection",
            "type": "->"
        },
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/app/Models/ChecklistModel.php",
            "line": 35,
            "function": "query",
            "class": "CodeIgniter\\Database\\BaseConnection",
            "type": "->"
        },
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/app/Controllers/Checklist.php",
            "line": 58,
            "function": "getSiteByPVIN",
            "class": "App\\Models\\ChecklistModel",
            "type": "->"
        },
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/app/Controllers/Checklist.php",
            "line": 48,
            "function": "get_site_information",
            "class": "App\\Controllers\\Checklist",
            "type": "->"
        },
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/system/CodeIgniter.php",
            "line": 943,
            "function": "check_site_information",
            "class": "App\\Controllers\\Checklist",
            "type": "->"
        },
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/system/CodeIgniter.php",
            "line": 503,
            "function": "runController",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/system/CodeIgniter.php",
            "line": 361,
            "function": "handleRequest",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/var/www/vhosts/mydomain.com/install.mydomain.com/public/index.php",
            "line": 79,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        }
    ]
}
Reply


Messages In This Thread
CL4 Connecting to a Remote AWS Database - by cx3700 - 04-30-2024, 08:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB