System.InvalidOperationException: Sequence contains more than one matching element

Sonarr version (exact version): v4.0.16.2942
Mono version (if Sonarr is not running on Windows): unable to check
OS: unraid
Debug logs:

2025-11-04 00:15:05.4|Fatal|SonarrErrorPipeline|Request Failed. GET /api/v3/series

[v4.0.16.2942] System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
   at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at Sonarr.Api.V3.Series.SeriesController.LinkSeriesStatistics(SeriesResource resource, SeriesStatistics seriesStatistics) in ./Sonarr.Api.V3/Series/SeriesController.cs:line 266
   at Sonarr.Api.V3.Series.SeriesController.LinkSeriesStatistics(List`1 resources, Dictionary`2 seriesStatistics) in ./Sonarr.Api.V3/Series/SeriesController.cs:line 248
   at Sonarr.Api.V3.Series.SeriesController.AllSeries(Nullable`1 tvdbId, Boolean includeSeasonImages) in ./Sonarr.Api.V3/Series/SeriesController.cs:line 125
   at lambda_method24(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Sonarr.Http.Middleware.BufferingMiddleware.InvokeAsync(HttpContext context) in ./Sonarr.Http/Middleware/BufferingMiddleware.cs:line 28
   at Sonarr.Http.Middleware.IfModifiedMiddleware.InvokeAsync(HttpContext context) in ./Sonarr.Http/Middleware/IfModifiedMiddleware.cs:line 41
   at Sonarr.Http.Middleware.CacheHeaderMiddleware.InvokeAsync(HttpContext context) in ./Sonarr.Http/Middleware/CacheHeaderMiddleware.cs:line 33
   at Sonarr.Http.Middleware.StartingUpMiddleware.InvokeAsync(HttpContext context) in ./Sonarr.Http/Middleware/StartingUpMiddleware.cs:line 38
   at Sonarr.Http.Middleware.UrlBaseMiddleware.InvokeAsync(HttpContext context) in ./Sonarr.Http/Middleware/UrlBaseMiddleware.cs:line 29
   at Sonarr.Http.Middleware.VersionMiddleware.InvokeAsync(HttpContext context) in ./Sonarr.Http/Middleware/VersionMiddleware.cs:line 29
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Description of issue:
I can’t load the sonarr web ui, it gives me the error Sequence contains more than one matching element. If I check the logs, it shows the above stack trace. I enabled trace logs too but they don’t reveal any additional logs with the error.

image

I tried reverting the database to an earlier version from a few days ago. I can then access the UI, but only for a few minutes before importing happens and I get the above error if I ever refresh the UI. I recently imported episodes from One Piece so not sure if that is related. I also tried running the housekeeping task, using Managarr, that didn’t fix it.

Ok so for anyone who runs into this, this is what I finally ended up doing, I deleted all series and started over. This was actually easier than I thought, I didn’t need to manually import hundreds of episodes like I had done before for several series, since I did not delete any files.

To start, I reverted the db to an earlier version that I knew was working, right after Sonarr started, I went to the Series page, selected all Series, and deleted them all, being careful not to delete folders with all the media files.

Next, you’re going to want to go to your download client, and set a Post-Import Category. Do this both in Sonarr Download Clients settings, and in the client itself, update the category of your imported torrents. I didn’t do this before adding the series back, and a bunch of episodes got re-imported, which may mess up your previously manually imported files. If you’re using Plex, it will also trigger tasks for newly imported episodes, since it thinks they’re new files.

Lastly, you can re-add all your series again by using Library Import, which will look at where your media files and hopefully auto fill in the correct series. I did have to adjust the Series Type for anime series since it didn’t auto select that option.