mongodb/mongoid · error · Mongoid::Errors::MixedClientConfiguration

Both uri and standard configuration options defined for clie

Error message

Both uri and standard configuration options defined for client: '%{name}'.

What it means

Error "Both uri and standard configuration options defined for client: '%{name}'." thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/config/validators/client.rb:74

          return unless no_hosts_or_uri?(config)

          raise Errors::NoClientHosts.new(name, config)
        end

        # Validate that not both a uri and standard options are provided for a
        # single client.
        #
        # @api private
        #
        # @example Validate the uri and options.
        #   validator.validate_client_uri(:default, {})
        #
        # @param [ String | Symbol ] name The config key.
        # @param [ Hash ] config The configuration.
        def validate_client_uri(name, config)
          return unless both_uri_and_standard?(config)

          raise Errors::MixedClientConfiguration.new(name, config)
        end

        # Return true if the configuration has no database or uri option
        # defined.
        #
        # @api private
        #
        # @example Validate the options.
        #   validator.no_database_or_uri?(config)
        #
        # @param [ Hash ] config The configuration options.
        #
        # @return [ true | false ] If no database or uri is defined.
        def no_database_or_uri?(config)
          !config.has_key?(:database) && !config.has_key?(:uri)
        end

        # Return true if the configuration has no hosts or uri option

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/config/validators/client.rb:74 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23). Data as JSON: /api/errors/4f87c6d1b88ecd26. Report an issue: GitHub.