microsoft/aspire · error · InvalidOperationException

No endpoints specified. Ensure a valid connection string…

Error message

No endpoints specified. Ensure a valid connection string was provided in 'ConnectionStrings:{connectionName}' or for the '{configurationSectionName}:ConnectionString' configuration key.

What it means

Aspire resolves Redis ConfigurationOptions from DI options (bound from connection string or configuration). When the resolved ConfigurationOptions is null or has no endpoints, a connection cannot be attempted, so the factory throws with guidance on where to supply the connection string.

Solutions

  1. Add the connection string: ConnectionStrings:redis = localhost:6379 (or a full redis:// URI).
  2. Register ConfigurationOptions in code via builder.AddRedisClient(name).WithConfiguration(...) or services.Configure<ConfigurationOptions>(...) if not using a connection string.
  3. Run through the Aspire AppHost with .WithReference(redis) so the endpoint is injected.
  4. Check that the connection name used in AddRedisClient matches the configured key (especially for keyed clients).

Example fix

// before
builder.AddRedisClient("cache"); // ConnectionStrings:cache missing

// after (appsettings.json)
// { "ConnectionStrings": { "cache": "localhost:6379" } }
builder.AddRedisClient("cache");
Defensive patterns

Strategy: validation

Validate before calling

var cs = builder.Configuration.GetConnectionString("redis");
if (string.IsNullOrEmpty(cs))
    throw new InvalidOperationException("Redis connection string missing: set ConnectionStrings:redis.");

Try / catch

try { builder.AddRedisClient("redis"); }
catch (InvalidOperationException ex) when (ex.Message.Contains("No endpoints specified"))
{ /* fail fast with config guidance or provide default localhost options */ }

Prevention

When it happens

Trigger: ConnectionMultiplexer factory (connection) invoked when 'ConnectionStrings:{connectionName}' is missing/empty and no ConfigurationOptions were registered via ConfigureStackExchangeRedis, so the IOptions/IOptionsMonitor value has zero EndPoints.

Common situations: Running the service outside the Aspire AppHost so the connection string was never injected; misnamed connection name; ConfigurationOptions bound from an empty config section; keyed options requested with a name that was never configured.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/c5f49e08f8cfed15. Report an issue: GitHub.

Appendix: source

Thrown at src/Components/Aspire.StackExchange.Redis/AspireRedisExtensions.cs:206

    {
        var connection = ConnectionMultiplexer.Connect(GetConfigurationOptions(serviceProvider, connectionName, configurationSectionName, optionsName));

        // Add the connection to instrumentation
        var instrumentation = serviceProvider.GetService<StackExchangeRedisInstrumentation>();
        instrumentation?.AddConnection(connection);

        return connection;
    }

    private static ConfigurationOptions GetConfigurationOptions(IServiceProvider serviceProvider, string connectionName, string configurationSectionName, string optionsName)
    {
        var configurationOptions = string.IsNullOrEmpty(optionsName) ?
            serviceProvider.GetRequiredService<IOptions<ConfigurationOptions>>().Value :
            serviceProvider.GetRequiredService<IOptionsMonitor<ConfigurationOptions>>().Get(optionsName);

        if (configurationOptions is null || configurationOptions.EndPoints.Count == 0)
        {
            throw new InvalidOperationException($"No endpoints specified. Ensure a valid connection string was provided in 'ConnectionStrings:{connectionName}' or for the '{configurationSectionName}:ConnectionString' configuration key.");
        }

        // ensure the LoggerFactory is initialized if someone hasn't already set it.
        configurationOptions.LoggerFactory ??= serviceProvider.GetService<ILoggerFactory>();

        return configurationOptions;
    }

    private static ConfigurationOptions BindToConfiguration(ConfigurationOptions options, IConfiguration configuration)
    {
        var configurationOptionsSection = configuration.GetSection("ConfigurationOptions");
        configurationOptionsSection.Bind(options);

        return options;
    }

    /// <summary>
    /// Used to pass StackExchangeRedisSettings instances to the ConfigurationOptionsFactory.

View on GitHub (pinned to 25830f84bd)