Solve login failed error for IIS APPPOOL\DefaultAppPool
I recently ran into the classic SQL Server connection error message "Login failed". This, of course, nearly always has to do with insufficient rights to the database.
However, I also got this error message:
Login failed for user 'IIS APPPOOL\DefaultAppPool
In this case, I tried to anonymously connect to a SQL Server Database (in Windows 7, mind).
This is how to solve the problem:
- In Internet Information Services, right click the website that tries to connect to the database->choose Manage Web Site -> Advanced Settings. Take a look at the Application Pool used, in this case DefaultAppPool:

- Now that you know the application pool the website uses, instead right click Application Pools (in IIS root) -> right click the correct application pool -> choose Advanced Settings.
- Under Advanced Settings, find Identity and choose LocalService as the Built-in account (or LocalSystem if that's the option you've got):

- Done!