---
title: "How do I override the SearchStax connection settings through settings.php?"
date: "2026-02-23T04:22:01+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/96311-how-do-i-override-searchstax-connection-settings-through-settingsphp"
id: "a497c799-ad41-43b3-944d-fe8a3ddc3edf"
---

After you move databases between environments, such as when you pull a production database to a local or development environment, a high risk of index pollution exists. Index pollution occurs because local CRUD operations or configuration changes trigger Search API to send updates to the production Solr index.

Use `settings.php` configuration overrides to enforce environment-specific connection settings. This ensures that the local environments remain safely disconnected from production search cores.

    /**
     * SearchStax Connection Settings Override.
     *
     * This override prevents local environments from writing to production indexes
     * by explicitly clearing credentials in non-production environments.
     * This code is just an example demonstration which you can adjust to your needs
     */
    
    // Determine the environment. For Acquia, use the AH_SITE_ENVIRONMENT variable.
    $production = (isset($_ENV['AH_SITE_ENVIRONMENT']) && $_ENV['AH_SITE_ENVIRONMENT'] === 'prod');
    
    if ($production) {
      // Production: Enforce live connection settings.
    
      $token = '161d4a5c5f31a6c706c1c003248eb3bf71e5';
      $host = 'searchcloud-4-eu-west-1.searchstax.com';
      $context = '123456';
      $core = 'core-123';   
    
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['update_token'] = $token  
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['host'] = $host;
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['context'] = $context;
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['core'] = $core;
      // The update_endpoint is an aggregate of the above variables
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['update_endpoint'] = 'https://' . $host . '/' . $context . '/' . $core . '/update';
      
    
    } else {
      // Non-Production: Nullify settings for safety.
      // This ensures local environments cannot authenticate with the SearchStax API.
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['update_token'] = '';
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['host'] = ''; 
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['context'] = '';
      $config['search_api.server.server_machine_name']['backend_config']['connector_config']['core'] = ''; 
    }

Values that you define in `$config` in `settings.php` take precedence over values in the Drupal database. After the SearchStax connector attempts to establish a connection, it uses these runtime overrides instead of the values imported with the production database.

Note

Configuration overrides do not appear in the Drupal admin UI. The fields at `/admin/config/search/search-api/server/[server_id]/edit` continue to display the database-stored values. To ensure that your overrides are active, run the following Drush command:

`drush config:get search_api.server.server_machine_name --include-overridden`

To ensure that values reflect in the Drupal admin UI, you must use a custom module to store those values. A proof of concept module is available at [drupal.org](https://www.drupal.org/project/searchstax/issues/3564133)[Drupal.org](https://www.drupal.org/project/searchstax/issues/3564133).