{"record":{"id":"c5f49e08f8cfed15","repo":"microsoft/aspire","slug":"no-endpoints-specified-ensure-a-valid-connection-string-was","errorCode":null,"errorMessage":"No endpoints specified. Ensure a valid connection string was provided in 'ConnectionStrings:{connectionName}' or for the '{configurationSectionName}:ConnectionString' configuration key.","messagePattern":"No endpoints specified\\. Ensure a valid connection string was provided in 'ConnectionStrings:(.+?)' or for the '(.+?):ConnectionString' configuration key\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Aspire.StackExchange.Redis/AspireRedisExtensions.cs","lineNumber":206,"sourceCode":"    {\n        var connection = ConnectionMultiplexer.Connect(GetConfigurationOptions(serviceProvider, connectionName, configurationSectionName, optionsName));\n\n        // Add the connection to instrumentation\n        var instrumentation = serviceProvider.GetService<StackExchangeRedisInstrumentation>();\n        instrumentation?.AddConnection(connection);\n\n        return connection;\n    }\n\n    private static ConfigurationOptions GetConfigurationOptions(IServiceProvider serviceProvider, string connectionName, string configurationSectionName, string optionsName)\n    {\n        var configurationOptions = string.IsNullOrEmpty(optionsName) ?\n            serviceProvider.GetRequiredService<IOptions<ConfigurationOptions>>().Value :\n            serviceProvider.GetRequiredService<IOptionsMonitor<ConfigurationOptions>>().Get(optionsName);\n\n        if (configurationOptions is null || configurationOptions.EndPoints.Count == 0)\n        {\n            throw new InvalidOperationException($\"No endpoints specified. Ensure a valid connection string was provided in 'ConnectionStrings:{connectionName}' or for the '{configurationSectionName}:ConnectionString' configuration key.\");\n        }\n\n        // ensure the LoggerFactory is initialized if someone hasn't already set it.\n        configurationOptions.LoggerFactory ??= serviceProvider.GetService<ILoggerFactory>();\n\n        return configurationOptions;\n    }\n\n    private static ConfigurationOptions BindToConfiguration(ConfigurationOptions options, IConfiguration configuration)\n    {\n        var configurationOptionsSection = configuration.GetSection(\"ConfigurationOptions\");\n        configurationOptionsSection.Bind(options);\n\n        return options;\n    }\n\n    /// <summary>\n    /// Used to pass StackExchangeRedisSettings instances to the ConfigurationOptionsFactory.","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.StackExchange.Redis/AspireRedisExtensions.cs#L188-L224","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the connection string: ConnectionStrings:redis = localhost:6379 (or a full redis:// URI).","Register ConfigurationOptions in code via builder.AddRedisClient(name).WithConfiguration(...) or services.Configure<ConfigurationOptions>(...) if not using a connection string.","Run through the Aspire AppHost with .WithReference(redis) so the endpoint is injected.","Check that the connection name used in AddRedisClient matches the configured key (especially for keyed clients)."],"exampleFix":"// before\nbuilder.AddRedisClient(\"cache\"); // ConnectionStrings:cache missing\n\n// after (appsettings.json)\n// { \"ConnectionStrings\": { \"cache\": \"localhost:6379\" } }\nbuilder.AddRedisClient(\"cache\");","handlingStrategy":"validation","validationCode":"var cs = builder.Configuration.GetConnectionString(\"redis\");\nif (string.IsNullOrEmpty(cs))\n    throw new InvalidOperationException(\"Redis connection string missing: set ConnectionStrings:redis.\");","typeGuard":null,"tryCatchPattern":"try { builder.AddRedisClient(\"redis\"); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"No endpoints specified\"))\n{ /* fail fast with config guidance or provide default localhost options */ }","preventionTips":["Provide ConnectionStrings:redis in every environment (appsettings, user secrets, env vars).","For non-connection-string setups, explicitly configure ConfigurationOptions via ConfigureStackExchangeRedis.","Verify keyed option names match when using AddKeyedRedisClient."],"tags":["redis","connection-string","missing-configuration","endpoints"],"backgroundTag":"missing-required-config","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}