Umbraco website doesn't connect to db when setting up website via IIS
Hello Folks,
I have a problem when trying to set up an Umbraco website with IIS 10.
When i'm going to the website i get "Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database. ".
The connection string is the following in my web.config file - Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=mytestdb; . Interesting thing is when i open the very same website through VS 2015 File - Open - Website and then launch it - everything works fine. For the moment i use windows authentication, but when i tried server credentials the result was the same. I've also noticed that my localdb instance belongs to MS SQL Server 2016. Firstly i thought that this might be the case, but why then everything works through visual studio. Will appreciate any advise if someone faced that issue.
I think I understand what you mean, but apologies if I haven't!
It sounds like when using windows authentication to connect to the database that your local visual studio debugging version uses your currently logged in user credentials, which has access to the database! - but when running the sitevia IIS, the website isn't using your credentials, it will be running as the app pool account, which I'm guessing doesn't have access to the database.
I would probably use SQL Authentication for the IIS version of the site (though so much depends on your network and what you are trying to achieve)
So using SQL Enterprise Manager create a sql login to the sql server and provide it with dbo permimssions to the Umbraco database; then create a new connection via SQL Enterprise Manager to the Umbraco database using the credentials you have just created - this verifys the connection is working for your newly created username and password.
Now update the connection string in IIS to use Sql Authentication when connecting to the database then it should work... (or at least highlight it isn't an authentication issue)
Unfortunately, i've already tried to change Authentication from Windows to SQL Server. I've created a new login and user. Before adding this connetcion string to the website i'm trying to run via IIS, i double checked the access to the database in Microsoft SQL Server Management Studio with new credentials. Everything works. I also checked seetings in IIS in conncetion string section, but they are identical to the ones in web.config file. Still no success. After that i tried changing App pool Identity settings (ApplicationPoolIdentity, NetworkService or even set up custom account).
Website works through VS, but not through IIS. Here is what i have in logs:
2017-03-16 15:47:38,129 [10] INFO Umbraco.Core.PluginManager -
[P40160/T1/D6] Starting resolution types of umbraco.interfaces.IApplicationStartupHandler
2017-03-16 15:47:38,137 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of umbraco.interfaces.IApplicationStartupHandler, found 42 (took 7ms)
2017-03-16 15:47:38,204 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.PropertyEditors.IPropertyEditorValueConverter
2017-03-16 15:47:38,205 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.PropertyEditors.IPropertyEditorValueConverter, found 0 (took 0ms)
2017-03-16 15:47:38,205 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.PropertyEditors.IPropertyValueConverter
2017-03-16 15:47:38,206 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.PropertyEditors.IPropertyValueConverter, found 21 (took 1ms)
2017-03-16 15:47:38,212 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Web.Mvc.SurfaceController
2017-03-16 15:47:38,213 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Web.Mvc.SurfaceController, found 5 (took 0ms)
2017-03-16 15:47:38,214 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Web.WebApi.UmbracoApiController
2017-03-16 15:47:38,216 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Web.WebApi.UmbracoApiController, found 37 (took 2ms)
2017-03-16 15:47:38,246 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.Media.IThumbnailProvider
2017-03-16 15:47:38,247 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.Media.IThumbnailProvider, found 3 (took 1ms)
2017-03-16 15:47:38,247 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.Media.IImageUrlProvider
2017-03-16 15:47:38,248 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.Media.IImageUrlProvider, found 1 (took 0ms)
2017-03-16 15:47:53,597 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:54,598 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:55,602 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:56,603 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:57,605 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:58,608 [10] ERROR Umbraco.Core.UmbracoApplicationBase - [P40160/T1/D6] An unhandled exception occurred
Umbraco.Core.Exceptions.UmbracoStartupFailedException: Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database.
at Umbraco.Core.CoreBootManager.EnsureDatabaseConnection()
at Umbraco.Core.CoreBootManager.Complete(Action1 afterComplete)
at Umbraco.Web.WebBootManager.Complete(Action1 afterComplete)
at Umbraco.Core.UmbracoApplicationBase.StartApplication(Object sender, EventArgs e)
When trying to connect to the database using SQL Authentication, what does your connection string look like (don't put passwords in)... ?
Secondly in my head reading your post, I've kind of assumed IIS is on the same machine as you are working in Visual Studio - (but if not, and it's on another server, create an ODBC connection from that server to the SQL database to confirm it has access over the network)
When entering via MS SQL Management studio everything is fine, when via IIS the same "Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database. "
Secondly in my head reading your post, I've kind of assumed IIS is on the same machine as you are working in Visual Studio.
Yep, you're right. We're talking about the same machine
I've also created new umbraco website, using MS SQL CE as db.
I could successfully reach it via IIS. This is connection string there:
add name="umbracoDbDSN" connectionString="Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;" providerName="System.Data.SqlServerCe.4.0"
The database was stored in App_Data folder.
I also tried to mimic this path and added |DataDirectory|\ to connection string and transferred database to App_Data folder. Unfortunately, agian no luck.
Umbraco website doesn't connect to db when setting up website via IIS
Hello Folks,
I have a problem when trying to set up an Umbraco website with IIS 10. When i'm going to the website i get "Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database. ". The connection string is the following in my web.config file - Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=mytestdb; . Interesting thing is when i open the very same website through VS 2015 File - Open - Website and then launch it - everything works fine. For the moment i use windows authentication, but when i tried server credentials the result was the same. I've also noticed that my localdb instance belongs to MS SQL Server 2016. Firstly i thought that this might be the case, but why then everything works through visual studio. Will appreciate any advise if someone faced that issue.
Hi Incred1ble
I think I understand what you mean, but apologies if I haven't!
It sounds like when using windows authentication to connect to the database that your local visual studio debugging version uses your currently logged in user credentials, which has access to the database! - but when running the sitevia IIS, the website isn't using your credentials, it will be running as the app pool account, which I'm guessing doesn't have access to the database.
I would probably use SQL Authentication for the IIS version of the site (though so much depends on your network and what you are trying to achieve)
So using SQL Enterprise Manager create a sql login to the sql server and provide it with dbo permimssions to the Umbraco database; then create a new connection via SQL Enterprise Manager to the Umbraco database using the credentials you have just created - this verifys the connection is working for your newly created username and password.
Now update the connection string in IIS to use Sql Authentication when connecting to the database then it should work... (or at least highlight it isn't an authentication issue)
regards
Marc
Hi Marc,
Thanks for suggested approach.
Unfortunately, i've already tried to change Authentication from Windows to SQL Server. I've created a new login and user. Before adding this connetcion string to the website i'm trying to run via IIS, i double checked the access to the database in Microsoft SQL Server Management Studio with new credentials. Everything works. I also checked seetings in IIS in conncetion string section, but they are identical to the ones in web.config file. Still no success. After that i tried changing App pool Identity settings (ApplicationPoolIdentity, NetworkService or even set up custom account).
Website works through VS, but not through IIS. Here is what i have in logs:
2017-03-16 15:47:38,129 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of umbraco.interfaces.IApplicationStartupHandler
2017-03-16 15:47:38,137 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of umbraco.interfaces.IApplicationStartupHandler, found 42 (took 7ms)
2017-03-16 15:47:38,204 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.PropertyEditors.IPropertyEditorValueConverter
2017-03-16 15:47:38,205 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.PropertyEditors.IPropertyEditorValueConverter, found 0 (took 0ms)
2017-03-16 15:47:38,205 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.PropertyEditors.IPropertyValueConverter
2017-03-16 15:47:38,206 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.PropertyEditors.IPropertyValueConverter, found 21 (took 1ms)
2017-03-16 15:47:38,212 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Web.Mvc.SurfaceController
2017-03-16 15:47:38,213 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Web.Mvc.SurfaceController, found 5 (took 0ms)
2017-03-16 15:47:38,214 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Web.WebApi.UmbracoApiController
2017-03-16 15:47:38,216 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Web.WebApi.UmbracoApiController, found 37 (took 2ms)
2017-03-16 15:47:38,246 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.Media.IThumbnailProvider
2017-03-16 15:47:38,247 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.Media.IThumbnailProvider, found 3 (took 1ms)
2017-03-16 15:47:38,247 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Starting resolution types of Umbraco.Core.Media.IImageUrlProvider
2017-03-16 15:47:38,248 [10] INFO Umbraco.Core.PluginManager - [P40160/T1/D6] Completed resolution of types of Umbraco.Core.Media.IImageUrlProvider, found 1 (took 0ms)
2017-03-16 15:47:53,597 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:54,598 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:55,602 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:56,603 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:57,605 [10] INFO Umbraco.Core.DatabaseContext - [P40160/T1/D6] CanConnect = False
2017-03-16 15:47:58,608 [10] ERROR Umbraco.Core.UmbracoApplicationBase - [P40160/T1/D6] An unhandled exception occurred Umbraco.Core.Exceptions.UmbracoStartupFailedException: Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database. at Umbraco.Core.CoreBootManager.EnsureDatabaseConnection() at Umbraco.Core.CoreBootManager.Complete(Action
1 afterComplete) at Umbraco.Web.WebBootManager.Complete(Action
1 afterComplete) at Umbraco.Core.UmbracoApplicationBase.StartApplication(Object sender, EventArgs e)2017-03-16 15:48:40,357 [10] INFO Umbraco.Core.UmbracoApplicationBase - [P40160/T1/D6] Application shutdown. Reason: InitializationError
Hi Incred1ble
When trying to connect to the database using SQL Authentication, what does your connection string look like (don't put passwords in)... ?
Secondly in my head reading your post, I've kind of assumed IIS is on the same machine as you are working in Visual Studio - (but if not, and it's on another server, create an ODBC connection from that server to the SQL database to confirm it has access over the network)
regards
Marc
Hi Marc,
Here how it looks like :
add connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=mytestdb;User ID=tdbuser;Password=**" name="umbracoDbDSN" providerName="System.Data.SqlClient"
Also tried:
add connectionString="Server=(localdb)\MSSQLLocalDB;Initial Catalog=mytestdb;User ID=tdbuser;Password=**" name="umbracoDbDSN" providerName="System.Data.SqlClient"
When entering via MS SQL Management studio everything is fine, when via IIS the same "Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database. "
Yep, you're right. We're talking about the same machine
I've also created new umbraco website, using MS SQL CE as db. I could successfully reach it via IIS. This is connection string there:
add name="umbracoDbDSN" connectionString="Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;" providerName="System.Data.SqlServerCe.4.0" The database was stored in App_Data folder.
I also tried to mimic this path and added |DataDirectory|\ to connection string and transferred database to App_Data folder. Unfortunately, agian no luck.
add connectionString="Data Source=|DataDirectory|\mytestdb;User ID=tdbuser;Password=**" name="umbracoDbDSN" providerName="System.Data.SqlClient"
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.