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,

    When i open Securit folder i cant see

    NT AUTHORITY/NETWORK SERVICE

    WHAT CAN I DO?

    Thanks

    Reply
  • Hi,

    The NT AUTHORITY/NETWORK SERVICE account is automatically created if the SQL Server service is run by NT AUTHORITY/NETWORK SERVICE account. Verify that your SQL server service account is different than this account.

    Regards,
    Pinal Dave

    Reply
    • Hi Dave,
      I find the thread in this website very helpful, however I have a question about ‘NT AUTHORITY\NETWORK SERVICE’ account, I am getting error “Cannot open database “MyDB.mdf” requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’. I have SQL Express 2008 and when I installed it I did not create that account. When I published my website in IIS I am getting that error. Why does my website use ‘NT AUTHORITY\NETWORK SERVICE’. I used windows authentication to login to my Server. My Website worked in Visual Studio. Hope you can help me with this. Thank you

      Reply
  • Hi, thanks for the replay

    Even on my developement computer there is no NT AUTORITY\NETWORK SERVICE;

    MY USERS IS:

    BUITLIN\ADMINISTRATOR
    BUILTIN\Users
    leo
    Leonel-PC\SQLServer2005MSSQ
    NT AUTORITY\SYSTEM
    sa

    is there any problem ? cos the System Works well on My computer but on my LAN Server does Not;

    i use windows server 2003 sp2;

    Is there any script to create this user?

    Thanks

    Reply
  • Thank you very much.excellent explain.Thanks a lot.

    Reply
  • Hello.
    And what to do in this case:

    Error of connection with a server -1:4060
    SQLSTATE = 42000
    Microsoft OLE DB Provider for SQL Server
    Cannot open database requested in login ‘MASTER’. Login fails.

    The result is identical on servers: 2000 SP4/2005/2008

    Thanks.

    Reply
  • Problem is fixed.

    Reply
  • Rajeev Kumar Singh
    March 18, 2010 12:35 pm

    Hi Sir,

    Thank U very much

    Reply
  • You have saved my day, again :)

    Thanks

    Reply
  • Wow!!!! after 3 days of trying to find why I keep getting this error:

    Cannot open database “” requested by the login. The login failed.

    “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.OleDb.OleDbException: Cannot open database “FTF” requested by the login. The login failed.

    DID EXACTLY WHAT YOU MENTIONED AND IT WORKED LIKE A CHARM. THANKS YOU SO MUCH !!!

    Reply
  • Hi people,

    my english is not good, but i will try to add something.

    my problem was the same, but i couldnt find the NT ACCOUNT,

    So i had to create this account and i had to make method the

    explained to in this spot.

    or try to use this script:

    /****** Object: Login [NT AUTHORITY\SYSTEM] Script Date: 03/20/2010 20:43:01 ******/
    /****** Object: Login [NT AUTHORITY\SYSTEM] Script Date: 03/20/2010 20:43:01 ******/
    CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english].

    be cool.

    Reply
  • Hi Dave,

    Hope you can help, I been working on connecting to a MSSQL Database for days, and still can’t solve the problem.
    I am developing on Windows 7 64 Notebook.

    I need to access (read) a database which is manage by a Commercial Software (say ‘A’), I am able to connect and work with when the Software A is not running, but when Software A is running my application cannot access the Database and vice versa.

    The database is set to Multiple_User for Restrict Access. The problem is my application must run when the Software A is running.

    I tested it, on its own when in Data Source (ODBC) test or in my application, it works find.

    This is my connection string:
    MSSQL_Con.ConnectionString = “Data Source=.SQLEXPRESS;Initial Catalog=” & TheDatabase & “;Integrated Security=SSPI;Trusted_Connection=No; Connect Timeout=30;User ID=AMS;Pwd=88888;”

    I had tried Integrated Security – True / False / SSPI
    Trusted Connect – True or False
    User Instance – Tru / False

    it still give me error:
    Cannot open database requested by the login. The login failed. Login failed for user ‘User1’
    User1 is created in Management Studio and tested OK without Software A.

    Please Sir, kindly Help.

    Best Regards

    Reply
  • Prince Mabizela
    March 24, 2010 8:24 pm

    Thanks buddy

    Sweet, short and clarified.

    Reply
  • Thanks :D
    saved my life!!!

    Reply
  • Hi I am getting below error:

    Cannot open database “FTNCorporateAutomation” requested by the login. The login failed.
    Login failed for user ‘NAM\at77221’.

    this is not specific to NT Athority

    Please advise asap.

    Thanks
    Sandeep

    Reply
  • Hello Sanddep,

    Please verify login’s access permission in database and Login’s default database. Are you able to connect through other logins or to other datrabases?

    Regards,
    Pinal Dave

    Reply
  • Hi guys

    I am getting exactly the same error. This is SQL Server 2000, IIS, ASP web pages, Windows 2000 Server setup. It worked perfectly until we had to restore the whole server due to a virus.

    So reformat, reinstall, etc, etc to a brand new (and virus protected) server.

    I’ve done everything that I did before, got all the correct permissions, etc and I still get this same error. I’ve done what you suggested above and it does not help. We have ODBC connections which work perfectly, we can access the database through a number of query tools.

    What have I missed? I am at my wits end.

    Reply
    • Marko Parkkola
      April 20, 2010 11:54 pm

      Could you make a little test and try to connect to master database with your login credentials? For example,write a little ASP.NET WebForm which connects to master db and tries to read something out of it.

      Reply
  • Hi Marko

    My problem is that I am not an ASP developer. This program was written a few years ago, and it just chugs along doing it’s thing …. until now. So I have no idea how to do what you are suggesting. I do know that we can connect to the db via ODBC from other pc’s ….

    I kind of think that the setup is wrong somehow but don’t know how or even where to look to correct it.

    Reply
    • Marko Parkkola
      April 21, 2010 11:43 pm

      Okay. Then you probably would want to check DB log files. See for entries where Source = Logon. It could be that your web page is not configured properly and it’s trying to connect with wrong credentials.

      Oh, and I just notice that you are talking about ASP pages, not ASP.NET. I know almost nothing about ASP so I’m not be able to help you much. Let’s hope the log reveals something enlightening.

      Reply
  • Thanks so much!
    this article is very help full!

    Thanks to you again

    Reply
  • i m trying to install SQL Server 2008 enterprise edition and i m getting error =CLR error 80004005 . dont now what to do. i try to change compatibalty still didnt work. plwase help

    Reply
  • ibrahim benkassem
    May 9, 2010 7:25 pm

    Hi,
    I can’t find ” NT AUTHORITY/NETWORK SERVICE ”
    please can you show how can i create this acount
    thanks a lot

    Reply

Leave a Reply