Unknown connection string. Name: 'master' error on CD server


Description

When a Sitecore XP instance is operating as a CD server, the cache is not refreshed and the following Exception appears:

Exception: System.InvalidOperationException
Message: Unknown connection string. Name: 'master'

The cause of this error is that eventQueue node references the Master database in the Sitecore.config file without the role:require attribute (while the master connection string is not present on the CD server).

Solution

To exclude Master database references, when the role is set to ContentDelivery, add the text highlighted in bold  to the EventQueue configuration in the Sitecore.config file:

<eventqueueprovider defaulteventqueue="core">
  <eventqueue role:require="ContentManagement or Standalone" name="master" type="Sitecore.Data.Eventing.$(database)EventQueue, Sitecore.Kernel">
    <param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)">
    <param hint="" ref="PropertyStoreProvider/store[@name='$(name)']">
  </eventqueue>
</eventqueueprovider>