Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cupcakedream's avatar

Enabling Secure Connection To Remote Database

Hey Everyone,

I'm trying connect to a remote database in my laravel app but I'm getting this error:

SQLSTATE[HY000] [3159] Connections using insecure transport are prohibited while --require_secure_transport=ON

I'm able to connect and run queries from the app server using the root user, so it appears to be an issue with Laravel.

Do I need to allow SSH for the www-data user? I also read there was a config option since 5.4 but it didn't work for me ( 'encrypt' => 'yes' ).

Any ideas?

0 likes
3 replies
Cronix's avatar

See if this helps: https://laracasts.com/discuss/channels/laravel/how-do-i-connect-to-a-mysql-database-over-ssl-with-laravel-53?page=1

You need to point to the ssl cert in the options array of the db connection.

Get rid of the 'encrypt' => 'yes'. That's bad info. It'd use true anyway if it were a real option instead of 'yes'.

It'd look something like:

'mysql' => [
    .............
    'options'   => [
        PDO::MYSQL_ATTR_SSL_KEY => '/path/to/client-key.pem',
        PDO::MYSQL_ATTR_SSL_CERT => '/path/to/client-cert.pem',
        PDO::MYSQL_ATTR_SSL_CA => '/path/to/ca-cert.pem',
    ],
],
cupcakedream's avatar

I tried adding all this but still nothing. I'm also getting a new 500 error:

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 122

I am stumped on this one. I have a local DB set up and that one works fine if I update the .env file. So I don't think it's a bad query.

Please or to participate in this conversation.