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
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.
In almost all such cases, this should fix your problem.
Reference : Pinal Dave (https://blog.sqlauthority.com)
225 Comments. Leave new
Thanx buudy. That solved my problem.
Thanx!! my prob has been solved.
Sir I want To access Master Database Table Through Asp.net
Pls Help Me
Thanks In advance
Have a connection string that points to Master database in your application
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…
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
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?
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
thanks alot
I don’t have NT AUTHORITY\NETWORK SERVICE. :( only the NT AUTHORITY\LOCAL SERVICE
Please help. thanks in advance. :)
thankyou
I like u r blog,answer is very straight forward,but still i got problem.this one different ‘ANGELICA-D45444ASPNET’.
I don’t have NT AUTHORITYNETWORK SERVICE. :( only the NT AUTHORITYLOCAL SERVICE
Please help. thanks in advance. :)
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?
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 ……….
Thanks Pinal…it helped a lot
Hello Pinal dave
you are GOD of sql server
i should have refer your blog four months back itself…
thank you very much
Guy…
u saved my day..
I almost gave up on this project!
U shaped my future – Thanks & May God bless u!
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 ?
Thankyou!!! Perfect solution…..
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