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

  • Thanx buudy. That solved my problem.

    Reply
  • Thanx!! my prob has been solved.

    Reply
  • Manoj Kopardekar
    December 8, 2011 6:26 pm

    Sir I want To access Master Database Table Through Asp.net
    Pls Help Me
    Thanks In advance

    Reply
  • Hi pinal,

    This is Rashmi.I am getting following error some times and not regularly.

    Cannot open database “xyz” requested by the login. The login failed.
    Login failed for user ‘xyz ‘.

    Please Help me…

    Reply
  • Hi, Mr. Pinal

    This is Rahul. And my problem is that

    A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 – An established connection was aborted by the software in your host machine.) (Microsoft SQL Server, Error: 10053)

    This problem is occured when i connect to SQLEXPRESS.
    Please help me out.

    Regards
    Rahul Singh

    Reply
  • your initial solution resolved my issue I was having after I restored my database from SQL 2000 to SQL 2005 server. Thank you.

    I stumbled upon this while doing many searches. What is the main link to this blog?

    Reply
  • Hey., i have trouble in logging to Primavera the error is “Bad public user name or password. Database Server Error: Encryption not supported on the client”.
    Kindly help

    Reply
  • thanks alot

    Reply
  • I don’t have NT AUTHORITY\NETWORK SERVICE. :( only the NT AUTHORITY\LOCAL SERVICE

    Please help. thanks in advance. :)

    Reply
  • thankyou

    Reply
  • I like u r blog,answer is very straight forward,but still i got problem.this one different ‘ANGELICA-D45444ASPNET’.

    Reply
  • I don’t have NT AUTHORITYNETWORK SERVICE. :( only the NT AUTHORITYLOCAL SERVICE

    Please help. thanks in advance. :)

    Reply
  • I got same Message when I try schedule job to email report from SQSReporting services. I created a new Subscription –> Notify by E-Mail–>
    Scheduling to run once. After I can see that Job created but Failed with error:
    ‘Execute as login’ failed for the requested login ‘NT AUTHORITY\NETWORK SERVICE’. SQL message id = 15406. I follow your instruction and mapped as you provided but still same problem. Do I need restart DB?

    Reply
  • microsoft .net application security warning

    I am getting the above error while installing sql server 2008 and i continued installation. After complete installation i am tryed to attach a database . I am getting the errors ……….

    Reply
  • Thanks Pinal…it helped a lot

    Reply
  • venkateshwar
    March 9, 2012 2:01 pm

    Hello Pinal dave
    you are GOD of sql server
    i should have refer your blog four months back itself…
    thank you very much

    Reply
  • Lewis Mugambi
    March 29, 2012 5:23 pm

    Guy…

    u saved my day..
    I almost gave up on this project!
    U shaped my future – Thanks & May God bless u!

    Reply
  • hi,
    when i try to open server from network computer,error message seen:cannot open database requested in login,login failed for user.

    how can i resolved this problem ?

    Reply
  • Thankyou!!! Perfect solution…..

    Reply
  • hi, I used SQLExpress, and in the mapping tab that you said, There is not my database that mentioned to this error; Please help me You can

    Reply

Leave a Reply