magento2: Connection "default" is not defined
getting Connection “default” is not defined when we run magento setup:upgrade in dockerfile. Below is my dockerfile
FROM bitnami/magento:2.4.2 WORKDIR opt/bitnami/magento COPY . . RUN composer require --no-update --dev magento/ece-tools magento/magento-cloud-docker RUN composer update RUN composer install RUN magento module:enable --all RUN magento setup:upgrade RUN magento setup:di:compile
Please help me in fixing this
Summary: Cannot install Magento without workaround mentioned above Environment: Any Linux system, dockerized or not
Steps to reproduce:
- create project with minimal
composer.jsonand runcomposer install
{
"type": "project",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"magento/product-community-edition": "2.4.5-p1"
},
"config": {
"use-include-path": true,
"allow-plugins": {
"magento/*": true,
"laminas/laminas-dependency-plugin": true,
"cweagans/composer-patches": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpro/grumphp-shim": true,
"phpstan/extension-installer": true
},
"preferred-install": "dist",
"sort-packages": true
},
"autoload": {
"psr-4": {
"Magento\\Setup\\": "setup/src/Magento/Setup/"
},
"files": [
"app/etc/NonComposerComponentRegistration.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**"
]
},
"repositories": {
"magento-marketplace": {
"type": "composer",
"url": "https://repo.magento.com/",
"only": [
"amzn/*",
"dotmailer/*",
"klarna/*",
"magento/*",
"msp/*",
"paypal/*",
"temando/*",
"vertex/*",
"yotpo/*"
]
}
},
"extra": {
"magento-force": "override"
},
"version": "2.4.5-p1"
}
- check out
app/etc/config.phpwith module information from a previously completed installation - run setup:install, e.g.
bin/magento setup:install --backend-frontname "admin" --db-host "db" --db-user "magento" --db-password "magento" --db-name "magento" --skip-db-validation --base-url="https://demo-magento2.lh/" --use-secure "1" --base-url-secure "https://demo-magento2.lh/" --search-engine "elasticsearch7" --elasticsearch-host "elasticsearch" --elasticsearch-port "9200" --elasticsearch-index-prefix "magento2" --admin-user "magento" --admin-password "magento123" --admin-email "info@example.com" --admin-firstname "Admin" --admin-lastname "User" --amqp-host="" --amqp-port="" --amqp-user="" --amqp-password="" --cleanup-database
Expected result: installation succeeds
Actual result: The following output
Starting Magento installation:
File permissions check...
[Progress: 1 / 1032]
Required extensions check...
[Progress: 2 / 1032]
Enabling Maintenance Mode...
[Progress: 3 / 1032]
Installing deployment configuration...
[Progress: 4 / 1032]
Cleaning up database...
Cleaning up database `magento`
[Progress: 5 / 1032]
Installing database schema:
Schema creation/updates:
Module 'Magento_Store':
...
[Progress: 1029 / 1032]
Disabling Maintenance Mode:
In ResourceConnection.php line 148:
Connection "default" is not defined
it is interesting though that with this minimal composer.json the error comes at the end when disabling maintenance mode, the database schema is already created at this point and following up with bin/magento setup:upgrade succeeds.
my previous issue happens with a more extensive composer.json where some default extensions and packages are installed together with Magento. I will try to narrow down the culprit
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 26 (14 by maintainers)
Same issue here on Magento 2.4.4 (Open Source) + PHP 8.1
Please stop assuming if one does not react within 14 days that the issue is “solved”. Especially if a number of people have encountered the same issue.
Can reproduce this issue with Magento 2.4.4 + PHP 8.1 In fact, it is completely impossible to install Magento from scratch without having various problems:
After running the installation again - without touching anyting - the process completes. BUT…
Then we have a redirection loop to /setup
This is totally insane how this framework is working… Event with the option cleanup-database you can have multiple issues trying to rerun the setup. Like “entity 1 not defined” and some other craps. This is by far the worst developer experience I ever had!
I could trace down this error at the end to a pre-existing
app/etc/config.php. We use this for some default configuration but even if it just contains themodulesinfo (exactly like after a complete installation), the error comes at the end of a new installation. Updating the comment above…That gives us another possible workaround: delete
app/etc/config.phpand restore it after installationI still try to find out what can cause the error at the beginning of the setup, no solution for that yet
It may be permission related issue. For quick fix comment below line. After completing installation you have to disable maintenance mode. $script[] = [‘Disabling Maintenance Mode:–’, ‘setMaintenanceMode’, [0]]; https://github.com/magento/magento2/blob/2.4.4/setup/src/Magento/Setup/Model/Installer.php#L371
Thanks @schmengler for the reply!
Your use case seems valid to me. Hence confirming this issue.
Thanks
@engcom-Hotel thanks and yes I do:
or to be more specific, the actual steps are:
I had the same issue. Deleting the database and recreate it before running the install seems to solve it.
Hi,
Got the same issue while installing Magento 2.4.4 and PHP 8.1.
Any help? on this
Hi Got the same issue. I am trying on Ubuntu machine Magento 2.4.4 + PHP 8.1.
[Progress: 1316 / 1319] Disabling Maintenance Mode:
In ResourceConnection.php line 148:
Connection “default” is not defined