SQL SERVER – FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’.

This error is quite common and I have received it few times while I was working on a recent consultation project.

Cannot open database requested by the login. The login failed.
Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’.

This error occurs when you have configured your application with IIS, and IIS goes to SQL Server and tries to login with credentials that do not have proper permissions. This error can also occur when replication or mirroring is set up.

If you search online, there are many different solutions provided to solve this error, and many of these solutions work fine. However, I will be going over a solution that works always and is very simple.

Fix/Workaround/Solution:

Go to SQL Server >> Security >> Logins and right click on NT AUTHORITY\NETWORK SERVICE and select Properties

SQL SERVER - FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. errnt

In newly opened screen of Login Properties, go to the “User Mapping” tab. Then, on the “User Mapping” tab, select the desired database – especially the database for which this error message is displayed. On the lower screen, check the role db_owner. Click OK.

SQL SERVER - FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. errnt1

In almost all such cases, this should fix your problem.

Reference : Pinal Dave (https://blog.sqlauthority.com)

SQL Error Messages, , SQL Scripts, SQL Server Security
Previous Post
SQLAuthority News – Two Virtual Tech Days Sessions – Watch it Online
Next Post
SQL SERVER – Get Query Plan Along with Query Text and Execution Count

Related Posts

225 Comments. Leave new

  • Hi again,

    I Tried also the Sharepoint 2010 Products Configuration wizard and this is part of the long list of the log file error.

    —–
    Login failed for user ‘ITLAB\Administrator’.
    04/18/2011 04:18:12 8 INF debugMessage for task initialize is An exception of type System.Data.SqlClient.SqlException was thrown. Additional exception information: Cannot open database “SharePoint_Config_fb7bd063-aee7-46ee-880d-e061c3279fb9” requested by the login. The login failed.
    Login failed for user ‘ITLAB\Administrator’.
    System.Data.SqlClient.SqlException: Cannot open database “SharePoint_Config_fb7bd063-aee7-46ee-880d-e061c3279fb9” requested by the login. The login failed.
    Login failed for user ‘ITLAB\Administrator’.
    at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
    at System.Data.SqlClient.SqlConnection.Open()
    at Microsoft.SharePoint.Utilities.SqlSession.OpenConnection()
    at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, CommandBehavior behavior, SqlQueryData monitoringData, Boolean retryForDeadLock)
    at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, Boolean retryForDeadLock)
    at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command)
    at Microsoft.SharePoint.Administration.SPLock.ReleaseStaleLock(SqlSession sqlsession, Int32 timeoutInSeconds)
    at Microsoft.SharePoint.Administration.SPLock.CleanupStaleSession()
    at Microsoft.SharePoint.Upgrade.SPManager.AcquireFarmUpgradeLock(Boolean bForce, Boolean singleClickInstall)
    at Microsoft.SharePoint.PostSetupConfiguration.InitializeTask.Run()
    at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()

    ——
    Thanks again in advance

    Reply
  • System.Data.SqlClient.SqlException: Cannot open database “Sports” requested by the login. The login failed.
    Login failed for user ‘TUSHAR\DP’.

    i will doing all changes u declard above but this error will occurd. plz tell me the solution.
    thank u.

    i wiil post my codng line below:
    {
    SqlConnection conn = new SqlConnection(“Data Source=Tushar\\SQLEXPRESS;Initial Catalog=Sports;Integrated Security=True;uid=tusharsim;Password=tusharsim”);
    }

    web.config code is:

    plz help me

    Reply
  • This solutions works perfect.
    Thanks a lot for saving a couple of my hours.
    Keep the good work going.

    Reply
  • Thanks a lot…
    This solutions works perfect.

    Reply
  • Thanks a lot……
    perfect site for solution ….

    Reply
  • im geeting the following error
    Cannot open database “userdatabase” requested by the login. The login failed.
    Login failed for user ‘DOTNET1\ASPNET’.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Cannot open database “userdatabase” requested by the login. The login failed.
    Login failed for user ‘DOTNET1\ASPNET’.

    i tried the above but it did’nt help ,the problem is im able to run on my local machine but not on shared network
    my connection string in web .config is above:-

    please help me out .

    Reply
  • May tell me about this messages :

    – SHUTDOWN is in progress. Login failed for user ‘xxx’. Only
    administrators may connect at this time.

    – Cannot open database “SignOnDB” requested by the login. The
    login failed. Login failed for user ‘xxx’.

    Reply
  • Karthik Varakala
    July 11, 2011 11:15 pm

    I’m using sqlserver 2005 in that i don’t have option like NTAuthority/network service what shall i do I’m getting this error

    Server Error in ‘/sam’ Application.
    ——————————————————————————–

    Cannot open database “karthik” requested by the login. The login failed.
    Login failed for user ‘HOME-91ECE83970ASPNET’.

    Reply
  • HI,

    Can you help me, i installed primavera in my pc but i cannot open any files on it, it happens only after i imported another file, previously it was okay until i did the last importing. Is there any connection with the sql server regarding this problem. I checked the database it says that database pmdb$primavera is not accessible ( microsoft.SQL server. Express. Object explorer) . Please help. Thank you

    Reply
  • Hello Dave, I get this error message in my log when attempting to run the config wizard in sharepoint 2010:
    Failed to connect to the database, and this is in the log.

    A System.Data.SqlClient.SqlException was thrown on server sqlxxx, database master

    Reply
  • SQL Server will NOT LET ME create a login for IIS APPPOOL\ASP.NET v4.0!!! Please help. I try and try but keep getting this error: “Windows NT user or group IIS APPPOOL\ASP.NET v4.0 not found. aaarrgghhh!!!

    Reply
  • You are my Hero!!! Thanks for solution :D

    Reply
  • good blog sir It works thanks.

    Reply
  • Excellent man.. im grateful to you, you saved my time. thanks..

    Reply
  • Hello All of u,
    My problem is “Microsoft OLE DB Provider for SQL Server error ‘80040e4d’

    Login failed for user ‘NT AUTHORITY\ANONYMOUS LOGON’ “i had tried first example of pinal to resolve it,then also,i am on same problem.
    Please help me out,
    Thanks in advance
    Jayanti

    Reply
  • Hi,

    This is ram,i want to study asp.net will u pls refer me some sites for learning easily with practical approach
    mail me [email removed]

    Reply
  • itguyprasanthprasanth
    November 2, 2011 8:14 pm

    Thank you very much, it solved my problem.

    Reply
  • I read the first few lines of this writeup and started smiling .. and it worked fine. thanks!

    Reply
  • Thanks – I must say you are the “man” and have helped me out a lot …

    Reply
  • Thank you so much! I google for problem solution often and have ended up in your site and found the right solution quite a few times. Kudo to you!

    Reply

Leave a Reply