Drupal 8: Configuration Originates From A Different Site

25th August 2020 - 3 minutes read time

One gotcha when importing configuration to a Drupal site can be a message that tells you that the configuration you are trying to import is from another site.

Here is the error that can be seen on the Configuration Synchronize page.

The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.

This error happens because the UUID of the site (in the database) is different to that in the configuration (in the code). The UUID in the code is stored in the configuration file system.site.yml. The reason for this check is to ensure that your don't destroy your Drupal site by installing configuration that was created from another site.

If the UUID doesn't match between the database and code then Drupal will refuse to accept it and will not import your config. This situation can arise from you installing a fresh copy of the site and needing to import your existing configuration over the top. As the site install generates a new UUID the two will be different and Drupal won't install your config.

There is a way around this, as long as you are sure this is what you want.

The easiest way to solve this is to overwrite the value in the configuration with the value in your database. The first step is to find out what the value is in your database by using Drush. The following command will print out your site UUID.

$ drush config-get "system.site" uuid
'system.site:uuid': d6eb07f8-16d0-4c62-8fac-7e1cc2cc7046

Using this you can then change the UUID at the top of the system.site.yml.

uuid: d6eb07f8-16d0-4c62-8fac-7e1cc2cc7046
name: 'My Awesome Drupal Website'
mail: [email protected]
slogan: 'Drupal site'
  403: ''
  404: ''
  front: /homapge
admin_compact_mode: false
weight_select_max: 100
langcode: en
default_langcode: en
  default_config_hash: ...
mail_notification: ''

You can also run this in reverse by forcing your site to have a particular UUID. Taking the UUID from your system.site.yml file and applying it to the site can be done in the following way.

$ drush config-set "system.site" uuid "d6eb07f8-16d0-4c62-8fac-7e1cc2cc7046"

Do you want to update uuid key in system.site config? (yes/no) [yes]:
 > yes

Either mechanism will then allow you to import your configuration as normal.

Add new comment

The content of this field is kept private and will not be shown publicly.