migrationdrupal-8drushddev

Connection refused when trying to use drush migrate-upgrade with DDEV (Drupal 7 to 8 upgrade)


I'm trying to use DDEV to locally test an upgrade of my running clubs's Drubal 7 website.

I've got one container with a copy of the website, result below is from the DDEV describe command:

    URLs
    ----
    https://drupalTest.ddev.site:8003
    https://127.0.0.1:32773
    http://drupalTest.ddev.site:8002
    http://127.0.0.1:32774

    MySQL/MariaDB Credentials
    -------------------------
    Username: "db", Password: "db", Default database: "db"

    or use root credentials when needed: Username: "root", Password: "root"

    Database hostname and port INSIDE container: db:3306
    To connect to db server inside container or in project settings files:
    mysql --host=db --user=db --password=db --database=db
    Database hostname and port from HOST: 127.0.0.1:32771
    To connect to mysql from your host machine,
    mysql --host=127.0.0.1 --port=32771 --user=db --password=db --database=db

    Other Services
    --------------
    MailHog (https):        https://drupalTest.ddev.site:8026
    MailHog:                http://drupalTest.ddev.site:8025
    phpMyAdmin (https):     https://drupalTest.ddev.site:8037
    phpMyAdmin:             http://drupalTest.ddev.site:8036

I also have a container with Drupal 8 (fresh install).

    URLs
    ----
    https://drupal8migration.ddev.site:8017
    https://127.0.0.1:32769
    http://drupal8migration.ddev.site:8016
    http://127.0.0.1:32770

    MySQL/MariaDB Credentials
    -------------------------
    Username: "db", Password: "db", Default database: "db"

    or use root credentials when needed: Username: "root", Password: "root"

    Database hostname and port INSIDE container: db:3306
    To connect to db server inside container or in project settings files:
    mysql --host=db --user=db --password=db --database=db
    Database hostname and port from HOST: 127.0.0.1:32797
    To connect to mysql from your host machine,
    mysql --host=127.0.0.1 --port=32797 --user=db --password=db --database=db

    Other Services
    --------------
    MailHog (https):        https://drupal8migration.ddev.site:8026
    MailHog:                http://drupal8migration.ddev.site:8025
    phpMyAdmin (https):     https://drupal8migration.ddev.site:8037
    phpMyAdmin:             http://drupal8migration.ddev.site:8036

I'm having problems getting the drush migrate-upgrade command to work, this is the

ddev exec drush migrate-upgrade --legacy-db-url=mysql://db:db@127.0.0.1:32771/db --legacy-root=https://drupalTest.ddev.site:8003 --configure-only

Just getting this error:

SQLSTATE[HY000] [2002] Connection refused                            [error]

Any help appreciatd


Solution

  • Welcome to ddev, Mark!

    Your problem is that you're using the wrong --legacy-db-url there. The credentials of the database are going to be:

    host: container name of the legacy install (like ddev--db) (NOT 127.0.0.1) Port: does not need to be specified, because it's the default 3306 (inside the docker container space)

    So it looks like you want something like this: ddev exec drush migrate-upgrade --legacy-db-url=mysql://db:db@ddev-drupaltest-db/db --legacy-root=https://drupalTest.ddev.site:8003 --configure-only

    See the faq under "Can different projects communicate with each other"

    I note that you seem to be using different http ports for different projects - you don't need to do that at all. The normal way to use ddev is for everything to be on ports 80 and 443 (or some other port set if you have conflicts). You do not need to set router_http_port or router_https_port just to run multiple projects on the same host.