Unable to connect to database when hosting website in IIS
Hi there,
I have just installed a new instance of Umbraco 7, but i am unable to run the website in IIS. I get the following errormessage when browsing to the website:
Cannot open database "<dbname>" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\<apppoolname>'.
I created a specific login and user for the database and used those credentials in the connectionstring which now looks like this:
The weird thing is when i run the project from Visual Studio the website works and i can add pages and do everything i want, so the connectionstring is correct but when its running under IIS it doesnt. Has anybody else experienced this issue?
That's weird - What approach did you take when installing Umbraco? Did you use nuget or a manual installation approach? And have you checked that you can access the database with the credentials provided using SQL server management studio for instance?
What database version are you using? Is it MSSQL? What version of IIS are you using? And what version of the .NET framework are you using? Is it 4.5?
And i have actually logged in using the same credentials in SQL Management Studio 2014 using an MSSQL database and i am able to connect and run queries on the database. Im using IIS 8.5 and the website is running under .Net 4.5.
By the path to the database, you mean the value in servername?
If the connectionstring is somehow incorrect, why am i able to connect and interact with the database when i run the website from Visual Studio? It seems that it is bypassing the UmbracoDSN when its running under IIS.
I just want to see what happens when you try to load the site outside of visual studio and when you load it from visual studio - The two scenarios that you have already described :)
The connectionstring wasnt wrong, because when i ran the project from Visual Studio that connectionstring is used for the database. I have actually already set up half of my website that way, created documenttypes and content. The error message suggests that the user 'IIS Apppool\' is unable to login in to the database. But the connectionstring doesnt contain the name of the apppool but a specified SQL login set up for this website. So it seems that the issue was caused by some setting in IIS. While i was creating this post i thought of checking the connectionstring in IIS, which should be the same as the one in the web.config and it actually was. However in IIS the option 'use Windows Integrated Security' was selected, so i changed that and specified the credential for the login, which were already specified in the connectionstring. So now it works. I have never come across this issue before and i have created numerous websites.
So this issue was resolved, thank you guys for your time!
I have selected my own post as the solution for this issue, i hope that is ok. If not, let me know.
Unable to connect to database when hosting website in IIS
Hi there,
I have just installed a new instance of Umbraco 7, but i am unable to run the website in IIS. I get the following errormessage when browsing to the website:
Cannot open database "<dbname>" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\<apppoolname>'.
I created a specific login and user for the database and used those credentials in the connectionstring which now looks like this:
<add name="umbracoDbDSN" connectionString="server=<server_name>;database=<dbname>;user id=<username>;password=<password>" providerName="System.Data.SqlClient" />
The weird thing is when i run the project from Visual Studio the website works and i can add pages and do everything i want, so the connectionstring is correct but when its running under IIS it doesnt.
Has anybody else experienced this issue?
Thanks in advance.
Hi Bunnynut
That's weird - What approach did you take when installing Umbraco? Did you use nuget or a manual installation approach? And have you checked that you can access the database with the credentials provided using SQL server management studio for instance?
What database version are you using? Is it MSSQL? What version of IIS are you using? And what version of the .NET framework are you using? Is it 4.5?
/Jan
Hi Jan,
Thank you for your reply.
I installed Umbraco though Nuget.
And i have actually logged in using the same credentials in SQL Management Studio 2014 using an MSSQL database and i am able to connect and run queries on the database.
Im using IIS 8.5 and the website is running under .Net 4.5.
Hi Bunnynut
Ok....hmm, perhaps that path to the database is wrong in your connectionstring in the web.config?
/Jan
Yes the connectionstring is in the web.config.
By the path to the database, you mean the value in servername?
If the connectionstring is somehow incorrect, why am i able to connect and interact with the database when i run the website from Visual Studio?
It seems that it is bypassing the UmbracoDSN when its running under IIS.
Hi Bunnynut
Yeah, I'm not sure about why you're able to run it using Visual Studio but not from within the browser.
Would it be possible for you to create a video so we can see the issue? Maybe that can give us a more clear idea about it.
/Jan
I Could try that, but what is you want to see exactly? Just to be sure so i dont cast Scarlett Johansen for nothing.
Hi Bunnynut
I just want to see what happens when you try to load the site outside of visual studio and when you load it from visual studio - The two scenarios that you have already described :)
/Jan
Not too sure about your issue. But I guess it seems that the problem on your connection string. Could you please check it again?
Hi John,
Ok, i seem to have fixed it.
The connectionstring wasnt wrong, because when i ran the project from Visual Studio that connectionstring is used for the database.
I have actually already set up half of my website that way, created documenttypes and content.
The error message suggests that the user 'IIS Apppool\' is unable to login in to the database. But the connectionstring doesnt contain the name of the apppool but a specified SQL login set up for this website. So it seems that the issue was caused by some setting in IIS.
While i was creating this post i thought of checking the connectionstring in IIS, which should be the same as the one in the web.config and it actually was. However in IIS the option 'use Windows Integrated Security' was selected, so i changed that and specified the credential for the login, which were already specified in the connectionstring. So now it works. I have never come across this issue before and i have created numerous websites.
So this issue was resolved, thank you guys for your time!
I have selected my own post as the solution for this issue, i hope that is ok. If not, let me know.
Hi Bunnynut
Happy to see you managed to figure it out - it makes sense that it did not work when using integrated security...:)
Have fun Umbracoing.
/Jan
is working on a reply...