Can't connect to PlanetScale with Symfony app

Hi, I have problem with connecting Symfony app with PlanetScale. This is the error I am getting:

An exception occurred in the driver: SQLSTATE[HY000] [1105] unknown error: Code: UNAVAILABLE  
  server does not allow insecure connections, client must use SSL/TLS   

This is my DATABASE_URL suggested by PlanetScale:


I also tried with following options (i’m not sure is this valid way to add options to db url?):


And this:


Unfortunately, nothing works.

If this can help there is my fly.toml:

app = "xnonxix"
primary_region = "lhr"

    NODE_VERSION = "20"
    PHP_VERSION = "8.2"
    SYMFONY_APP_ENV = "prod"

  SYMFONY_APP_ENV = "prod"
  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

  command = "bin/console doctrine:migrations:migrate --no-interaction"

Does anyone know what solve a problem? I’m not sure is the problem in my server setup, Symfony or PlanetScale?

Meanwhile I found solution, the problem was with my Symfony configuration.

Here is solution in case someone has the same problem:

You need to add MYSQL_ATTR_SSL_CA option to config/packages/doctrine.yaml:

        url: "%env(resolve:DATABASE_URL)%"
            !php/const:PDO::MYSQL_ATTR_SSL_CA: '%env(DATABASE_SSL_CA_PATH)%'

And then create env variable as DATABASE_SSL_CA_PATH=“/etc/ssl/certs/ca-certificates.crt”. That is correct path for (at least for my setup), could be different on different setups though.

I found solution here MySQL + SSL + Doctrine

I also found that there php package to handle this automatically (if you don’t know path of certification, it will find it automatically): Zero-Configuration SSL CA root bundles in Doctrine DBAL with Symfony | Colin O'Dell. I didn’t test does it work, above solution was easier for me.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.