We have defined the default web/secure/base_url like this in our app/etc/env.php of our Magento 2.4.2-p1 CE for example:

return [
    'system' => [
        'default' => [
            'web' => [
                'unsecure' => [
                    'base_url' => 'http://example.com/',
                'secure' => [
                    'base_url' => 'https://example.com/',

However, if we change these values in the env.php and then execute

$ bin/magento app:config:import
Processing configurations data from configuration file...
System config was processed

the actual database values in core_config_data do not change for the default scope of the web/secure/base_url path - even though the command confirmed "System config was processed" instead of "Nothing to import.". Curiously these values cannot be edited in the back end, as they are otherwise identified to be persisted via the config files.

We would like to persist the default base URLs for the respective environment via the env.php this way - however for some reason Magento is not actually updating the value in the database when executing setup:upgrade or app:config:import.

1 Answer 1


Actual values of unsecure and secure url path in the database core_config_data are not getting changed because

Magento directly uses values in the system array in the config.php or env.php files instead of importing them into the database because they require some pre- and post-processing actions.

See official documentation for more details.

If you want to write this values to env.php and also get it updated in the database, then try to set this configuration value using command line

bin/magento config:set --lock-env web/unsecure/base_url http://example.com/

Where --lock-env parameter either locks the value so it cannot be edited in the Magento Admin or changes a setting that is already locked in the Magento Admin. The command writes the value to the <Magento base dir>/app/etc/env.php file.

Check this for more details. Thanks!

  • Yes, I saw in the documentation afterwards, that these values are pulled directly from the config, instead of the database. However, in our case that did not work for some reason. Magento still used the base_url of the database for the back end and tried to redirect to that base_url instead of using the new base url from the env.php.
    – fritzmg
    May 26, 2021 at 7:52
  • In that case try to set configuration value using command line. May 26, 2021 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.