While accessing your DNN application in the web browser if you face Connection to database failed error, then there will be several possibilities for this error
Majorly this error occurs due to incorrect connection string in web.config file, you have to make sure that the database details you are entering in coding is matching with the database. Here is the sample of DNN connection string is mentioned below:
<connectionStrings>
<add name="SiteSqlServer" connectionString="Data
Source=SERVERNAME;Initial Catalog=DATABASENAME;User
ID=DATABASEUSER;Password=PASSWORD"
providerName="System.Data.SqlClient" />
</connectionStrings>
Another possibility is the use of special characters in the password:
You have to make sure that you have created a database password based on passwordregulerexpression and strength, you can reset database password and you have to enter the updated password in web.config file.
Another reason may be the database service is down OR under maintenance, you have to confirm this with your hosting service provider.