MassTransit/MassTransit · error · ConfigurationException
Consumer is excluded from ConfigureEndpoints
Error message
Consumer is excluded from ConfigureEndpoints
What it means
A consumer was explicitly removed from automatic endpoint configuration (ExcludeFromConfigureEndpoints), so calling Endpoint() on its registration configurator is a contradiction: the consumer opted out of ConfigureEndpoints, and per-consumer endpoint customization is only meaningful for consumers included in it. MassTransit throws ConfigurationException to prevent a silently-ignored configuration call.
Solutions
- Remove the ExcludeFromConfigureEndpoints() call if you want per-consumer Endpoint configuration.
- Remove the Endpoint(...) call and configure the receive endpoint manually if the consumer must stay excluded.
- Configure the endpoint inline when adding the consumer, e.g. via AddConsumer with the configure callback and an explicit endpoint definition.
Example fix
// before
x.AddConsumer<OrderConsumer>()
.ExcludeFromConfigureEndpoints()
.Endpoint(e => e.PrefetchCount = 10);
// after
x.AddConsumer<OrderConsumer>()
.Endpoint(e => e.PrefetchCount = 10); Defensive patterns
Strategy: validation
Validate before calling
if (consumerRegistration.ExcludeFromConfigureEndpoints)
throw new InvalidOperationException("Cannot call Endpoint() on a consumer excluded from ConfigureEndpoints."); Try / catch
try { registration.Endpoint(cfg => cfg.PrefetchCount = 10); }
catch (ConfigurationException ex) { logger.LogWarning(ex.Message); } Prevention
- Choose one configuration style per consumer: ConfigureEndpoints + Endpoint(), or fully manual endpoints.
- Search registrations for ExcludeFromConfigureEndpoints before adding Endpoint calls.
- Centralize consumer registration conventions in one extension method.
When it happens
Trigger: Calling .Endpoint(cfg => ...) on the IConsumerRegistrationConfigurator after having called .ExcludeFromConfigureEndpoints() on the same consumer registration.
Common situations: Copy-pasting registration code where one consumer was excluded from ConfigureEndpoints but still has endpoint customization; refactoring endpoint configuration from automatic to manual without removing the Endpoint() call.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- The scoped filter could not be added: {TypeCache<TConsumer>.
- Feature is excluded from ConfigureEndpoints
- Saga is excluded from ConfigureEndpoints
- No JSON serializer configured
- A topic consumer with the same key was already added: {speci
AI-assisted analysis of MassTransit/MassTransit@62ab339afa (2026-09-13).
Data as JSON: /api/errors/c2f5750b6f04a721.
Report an issue: GitHub.
Appendix: source
Thrown at src/MassTransit/DependencyInjection/DependencyInjection/Registration/Consumers/ConsumerRegistrationConfigurator.cs:23
public class ConsumerRegistrationConfigurator<TConsumer> :
IConsumerRegistrationConfigurator<TConsumer>
where TConsumer : class, IConsumer
{
readonly IRegistrationConfigurator _configurator;
readonly IConsumerRegistration _registration;
public ConsumerRegistrationConfigurator(IRegistrationConfigurator configurator, IConsumerRegistration registration)
{
_configurator = configurator;
_registration = registration;
}
public void Endpoint(Action<IEndpointRegistrationConfigurator> configure)
{
if (!_registration.IncludeInConfigureEndpoints)
throw new ConfigurationException("Consumer is excluded from ConfigureEndpoints");
var configurator = new EndpointRegistrationConfigurator<TConsumer>();
configure?.Invoke(configurator);
_configurator.AddEndpoint<ConsumerEndpointDefinition<TConsumer>, TConsumer>(_registration, configurator.Settings);
}
public void ExcludeFromConfigureEndpoints()
{
_registration.IncludeInConfigureEndpoints = false;
}
}
}
View on GitHub (pinned to 62ab339afa)