ServiceLocationProvider must be set – ERROR

Posted by
[InvalidOperationException:  ServiceLocationProvider must be set.]
   CommonServiceLocator.ServiceLocator.get_Current() +109
   Sitecore.ContentSearch.SolrProvider.SolrStatus.OkSolrStatus() +45
   Sitecore.ContentSearch.SolrProvider.SolrStatus..cctor() +72

[TypeInitializationException: The type initializer for 'Sitecore.ContentSearch.SolrProvider.SolrStatus' threw an exception.]
   Sitecore.ContentSearch.SolrProvider.SolrStatus.SetIndexForInitialization(ISearchIndex solrIndex) +0
   Sitecore.ContentSearch.SolrProvider.SolrSearchIndex.SetForReinitialization() +202
   Sitecore.ContentSearch.SolrProvider.SolrSearchIndex.InitializeSolr() +191
   Sitecore.ContentSearch.SolrProvider.SolrSearchIndex.Initialize() +47
   Sitecore.ContentSearch.ContentSearchConfiguration.AddIndex(ISearchIndex index) +411

Cause of this error is clear. Your Sitecore instance cannot connect to Solr. Reasons why can vary. Lets cover them one by one.

  • Check if your Solr is running.
    • Go to <solr_instance_url>:<solr_port> (ex. https://localhost:8983) and Solr should open.
  • Check Sitecore ConnectionString.config
    • solr.search should point to the correct address
  • Check if all Solr Cores are in your Solr instance
    • Sometimes, for one reason or another, the could be some default cores missing
  • Check Solr certificate
    • Your Solr instance should be accesible via https and it should be valid
  • If you are using local Solr instance, there could be a error in setup. If you’re accesing Solr instance via localhost try to access it via 127.0.0.1.Example:
    • https://localhost:8983
    • https://127.0.01:8983
    • Sometimes certificate setup has incorect CN data, where you didn’t defined 127.0.0.1 as local IP and Sitecore in some of the services will try to access Solr via 127.0.0.1 address which will lead to error above (where invalid certificate will throw an error)