Nopcommerce 4.30 - Intermittent 'Cannot open database requested by the login. Login failed for user...' message

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Since upgrading to 4.30 my site has been having periodic issues with the following error message:

SqlException: Cannot open database "*******" requested by the login. The login failed.
Login failed for user '*******'.


I'm running SQL Server and connecting via a SQL login that I created myself. To rule out issues I've updated the password for this login (both via my hosting (plesk) account and also in datasettings) but continue to have the issue every few days. I've had the same hosting for a decade and they are solid, so I don't believe the hosting to be the issue, but you never know... I never encountered this issue with 4.20 or previous versions. This is costing my business conversions and I'm pulling my hair out because it just doesn't make sense to me and I don't even know where to start investigating. Has anyone else has encountered similar problems.


Autofac.Core.DependencyResolutionException: An exception was thrown while activating λ:Nop.Core.Domain.Common.CommonSettings -> Nop.Data.Migrations.MigrationManager -> λ:FluentMigrator.Runner.IVersionLoader.
---> System.Data.SqlClient.SqlException (0x80131904): Cannot open database "**********" requested by the login. The login failed.
Login failed for user '**********'.
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at FluentMigrator.Runner.Processors.GenericProcessorBase.<>c__DisplayClass6_1.<.ctor>b__1()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location where exception was thrown ---
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at FluentMigrator.Runner.Processors.GenericProcessorBase.get_Connection()
   at FluentMigrator.Runner.Processors.GenericProcessorBase.EnsureConnectionIsOpen()
   at FluentMigrator.Runner.Processors.GenericProcessorBase.BeginTransaction()
   at FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessor.BeginTransaction()
   at FluentMigrator.Runner.TransactionalMigrationScope..ctor(IMigrationProcessor processor, Action disposalAction)
   at FluentMigrator.Runner.MigrationScopeHandler.BeginScope()
   at FluentMigrator.Runner.MigrationScopeHandler.CreateOrWrapMigrationScope(Boolean transactional)
   at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(IMigrationInfo migrationInfo, Boolean useTransaction)
   at FluentMigrator.Runner.MigrationRunner.Up(IMigration migration)
   at FluentMigrator.Runner.VersionLoader.LoadVersionInfo()
   at FluentMigrator.Runner.VersionLoader..ctor(IProcessorAccessor processorAccessor, IConventionSet conventionSet, IMigrationRunnerConventions conventions, IVersionTableMetaData versionTableMetaData, IMigrationRunner runner)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance[T](IServiceProvider provider, Object[] parameters)
   at Microsoft.Extensions.DependencyInjection.FluentMigratorServiceCollectionExtensions.<>c.<AddFluentMigratorCore>b__0_6(IServiceProvider sp)
   at Autofac.Extensions.DependencyInjection.AutofacRegistration.<>c__DisplayClass3_0.<Register>b__0(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
ClientConnectionId:bc490f9f-51a9-4270-9c1c-63cbdac26882
Error Number:4060,State:1,Class:11
   --- End of inner exception stack trace ---
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
   at Autofac.Core.Resolving.InstanceLookup.<>c__DisplayClass7_0.<Execute>b__0()
   at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
   at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
   at Nop.Core.Infrastructure.NopEngine.Resolve(Type type) in C:\**********\Libraries\Nop.Core\Infrastructure\NopEngine.cs:line 219
   at Nop.Core.Infrastructure.NopEngine.Resolve[T]() in C:\**********\Libraries\Nop.Core\Infrastructure\NopEngine.cs:line 206
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.UseNopResponseCompression(IApplicationBuilder application) in C:\**********\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationBuilderExtensions.cs:line 202
   at Nop.Web.Framework.Infrastructure.NopCommonStartup.Configure(IApplicationBuilder application) in C:\**********\Presentation\Nop.Web.Framework\Infrastructure\NopCommonStartup.cs:line 64
   at Nop.Core.Infrastructure.NopEngine.ConfigureRequestPipeline(IApplicationBuilder application) in C:\**********\Libraries\Nop.Core\Infrastructure\NopEngine.cs:line 195
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.ConfigureRequestPipeline(IApplicationBuilder application) in C:\**********\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationBuilderExtensions.cs:line 45
   at Nop.Web.Startup.Configure(IApplicationBuilder application) in C:\**********\Presentation\Nop.Web\Startup.cs:line 58
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__2(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at Nop.Web.Program.Main(String[] args) in C:\**********\Presentation\Nop.Web\Program.cs:line 12
  
3 years ago
When the problem happens can you still login to the database using the same credentials via another program ie SSMS ?
The question is how do you fix the problem?
Do you have to reset the password or does it just require a website restart ?
3 years ago
Yidna wrote:
When the problem happens can you still login to the database using the same credentials via another program ie SSMS ?
The question is how do you fix the problem?
Do you have to reset the password or does it just require a website restart ?


Good questions, thanks!

- I have been unable to catch the issue immediately after it happened. By the time I caught it I was able to access via SSMS. I'm going to set up a script to run and notify me as soon as the site goes down like this, so that I can better test.
- A website restart fixes the problem.
3 years ago
Are you using Database Authentication or Windows Authentication?
3 years ago
New York wrote:
Are you using Database Authentication or Windows Authentication?


Database authentication. The issue occurs on application restart, but only sporadically.
3 years ago
By any chance, have you found a solution? I'm still having this issue + I already have another website watching the nopcommerce one...
3 years ago
I solved this issue by changing in datasettings.json, IntegratedSecurity=False->True
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.