Skip to content

Magento 2.4.6 Project Community Edition failing on cloud deploy with error SQLSTATE[HY000] [2002] Connection refused

I am trying to build magento 2 project community edition locally. I am on a windows machine using ubuntu. Here is my process:

I run these commands:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition community
composer require --no-update --dev magento/ece-tools magento/magento-cloud-docker
composer update
./vendor/bin/ece-docker build:compose --mode="developer" --sync-engine="mutagen"
docker-compose up -d
bash mutagen.sh
 docker compose run --rm deploy cloud-deploy 

The last command is where I am getting stuck. Every time it gives me the error:

In Setup.php line 91:

  The command "/bin/bash -c "set -o pipefail; php ./bin/magento setup:install -n --ansi --no-interaction --cleanup-da
  tabase --session-save='db' --use-secure-admin='1' --use-rewrites='1' --currency='USD' --base-url='http://magento2.d
  ocker/' --base-url-secure='https://magento2.docker/' --backend-frontname='admin' --language='en_US' --timezone='Ame
  rica/Los_Angeles' --db-host='db' --db-name='magento2' --db-user='magento2' --db-password='******' --admin-user='adm
  in' --admin-firstname='Admin' --admin-lastname='Username' --admin-email='[email protected]' --admin-password='*****
  *' --search-engine='opensearch' --opensearch-host='opensearch' --opensearch-port='9200' | tee -a /app/var/log/insta
  ll_upgrade.log"" failed. In Abstract.php line 148:

    SQLSTATE[HY000] [2002] Connection refused
    ```

If i change the hots in app/etc/env.php to localhost the error changes to:

Fatal error: Declaration of MagentoIndexerConsoleCommandIndexerReindexCommandIntercep
tor::setDefinition(SymfonyComponentConsoleInputInputDefinition|array $definition): static must be compatible wi
th SymfonyComponentConsoleCommandCommand::setDefinition($definition) in /app/generated/code/Magento/Indexer/Con
sole/Command/IndexerReindexCommand/Interceptor.php on line 119