I have changed Base url in Magento 2.1, but it does not works.

While installing I have set base url to www.domain1.net. I need to change it to www.domain2.net.

What I tried:

  1. Update baseurl in core_config_data:

    UPDATE core_config_data
    SET value = 'http://www.domain2.net/' 
    WHERE path IN ('web/secure/base_url', 'web/unsecure/base_url');
  2. Replace design/head/includes/

    UPDATE core_config_data 
    SET value = REPLACE(value, 'http://www.domain1.net/', 'http://www.domain2.net/') 
    WHERE path = 'design/head/includes';

Then changed Store Url

 php bin/magento setup:store-config:set --base-url="http://www.domain2.net/"

 php bin/magento setup:store-config:set --base-url-secure="https://www.domain2.net/"

Finally cleared the cache:

php bin/magento cache:flush

After serach www.domain2.net it throw server not found.


What is it the right way to change Base url in magento 2.1?

  • 2
    Updated magento changed the name of the CLI command. Per php bin/magento list it says: setup:store-config:set Installs the store configuration. Deprecated since 2.2.0. Use config:set instead
    – tbernard
    Commented Dec 7, 2017 at 15:49
  • Did any of the answers below solve your problem? In my case, following your steps worked fine for me. What exactly did you mean by "server not found", was that error displayed within a Magento page? Sounds more likely a browser error page, implying that you had not added www.domain2.net to DNS or your hosts file. Commented Jan 24, 2018 at 17:10

3 Answers 3


First update both the web/unsecure/base_url and web/secure/base_url URLs in core_config_data to http://www.domain2.net/ in your database, you can use the above query.

Then, clear the cache by the below command.

sudo rm -rf var/cache var/generation var/page_cache

Ensure you have updated your virtual host settings according to the new URL.

Once you set the applied the virtual host changes, restart the apache server.

Now, browse with the new URL.


in addition to Sukeshinis answer I would also check what domain the magento-cookies are set for. Search in core_config_data for %cookie% and remove all the rows or replace them with the new domain. Because if you don't change or don't delete these, then it could be that you will be redirected to your old domain. Wasted alot of minutes on that problem


In my case, I had to change the web/unsecure/base_link_url also:

UPDATE core_config_data
-> SET value = 'http://www.domain2.net/'
-> WHERE path IN ('web/unsecure/base_link_url');

Your Answer

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

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