I been strugling with this for 2 days now without comming any closer to solution. I have read 20-30 threads alteast and stil can not resolve this.

Please help me out.

I have disable anonymous authentication, enable asp.net impersonation.

I have added <identity impersonate = "true" />

I have added the a user to the security logins that is connected to the database I try to connect to

This is the connectionstring I use:

Data Source=IPTOSERVER;Initial Catalog=Phaeton;User Id=User;Password=Password;


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

Login failed for user ‘NT AUTHORITYNETWORK SERVICE’.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I was experiencing a similar error message that I noticed in the Windows Event Viewer that read:

Login failed for user ‘NT AUTHORITYNETWORK SERVICE’. Reason: Failed to open the explicitly specified database. [CLIENT: local machine]

The solution that resolved my problem was:

  1. Login to SqlExpress via SQL Server Management Studio
  2. Go to the “Security” directory of the database
  3. Right-click the Users directory
  4. Select “New User…”
  5. Add ‘NT AUTHORITYNETWORK SERVICE’ as a new user
  6. In the Data Role Membership area, select db_owner
  7. Click OK

Here’s a screenshot of the above:
Screenshot of adding new user Network Service as db_owner to SqlExpress

Method 2

The error message you are receiving is telling you that the application failed to connect to the sqlexpress db, and not sql server.
I will just change the name of the db in sql server and then update the connectionstring accordingly and try it again.

Your error message states the following:

Cannot open database "Phaeton.mdf" requested by the login. The login failed.

It looks to me you are still trying to connect to the file based database, the name “Phaeton.mdf” does not match with your new sql database name “Phaeton”.

Hope this helps.

Method 3

If the error message is just

“Login failed for user ‘NT AUTHORITYNETWORK SERVICE’.”, then grant
the login permission for ‘NT AUTHORITYNETWORK SERVICE’

by using


else if the error message is like

“Cannot open database “Phaeton.mdf” requested by the login. The login
failed. Login failed for user ‘NT AUTHORITYNETWORK SERVICE’.”

try using


under your “Phaeton” database.

Method 4

I liked Jed’s solution but the issue with that was every time I built my project in debug mode, it would deploy my database project and removed the user again. so I added this MySQL script to the Post-Deployment script.
it practically does what Jed said but creates the user every time I deploy.


EXEC sp_addrolemember 'db_owner', 'NT AUTHORITYNETWORK SERVICE'

Method 5

You said it worked fine when you were using SQL Express edition. By default express editions create a named instance & run in NT AuthorityNetwork Service.

SQL Server STD by default install a default instance & run in NT AuthoritySYSTEM.

Do you have both the full SQL edition & Express edition installed on the same machine?

  1. It could be that somewhere the connection string still refers to the Named instance ‘SQLEXPRESS’ rather than the default instance created by the full version.
  2. Also where is the connection string defined? In IIS or your code? Make sure that if defined in many places, all point to same SQL instance & database.
  3. Also try looking at the detailed error present in the SQL Server error logs. The error logged in event log are not complete for secuirty reasons. This will also help you to know if the connection was made to the correct SQL Server.
  4. Also make sure that the machine on which SQL is installed is accessible & IIS is trying to access the same machine. In my company sometimes due to wrong name resolution, the query fails since most of our computers have SQL installed & the query lands in the wrong SQL Server.
  5. Make sure that the database exists in the SQL Server. The name displayed under databases in SQL Management Studio should match that in the connection string.

Method 6

The SQL Server login required is DOMAINmachinename$. This is the how the calling NT AUTHORITYNETWORK SERVICE appears to SQL Server (and file servers etc)



Method 7

The Best way is to create a user for your application and assign the permissions that are suitable for that user. Dont use ‘NT AUTHORITYNETWORK SERVICE’ as your user it has its own vulnerability and it is a user that has permissions to so many things on the OS level. Stay away from this built in user.

Method 8

I am using Entity Framework to repupulate my database, and the users gets overridden each time I generate my database.

Now I run this each time I load a new DBContext:

cnt.Database.ExecuteSqlCommand("EXEC sp_addrolemember 'db_owner', 'NT AUTHORITY\NETWORK SERVICE'");

Method 9

Make sure that the database is created. I got the same error when I applied the migration to the wrong project in the solution. When I applied the migration to the right project, it created the database and that solved the error.

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x