nopSolutions/nopCommerce · critical · Exception
Unable to connect to the new database. Please try one more t
Error message
Unable to connect to the new database. Please try one more time
What it means
Thrown at the end of MsSqlDataProvider.CreateDatabase when the freshly-created SQL Server database cannot be reached within the allotted retry window. After issuing CREATE DATABASE the method polls DatabaseExists() up to 'triesToConnect' times, sleeping 1 second between attempts; if the DB is still unreachable on the final iteration it throws a bare Exception, aborting the nopCommerce installation.
Source
Thrown at src/Libraries/Nop.Data/DataProviders/MsSqlDataProvider.cs:86
var command = connection.CreateCommand();
command.CommandText = query;
command.Connection.Open();
command.ExecuteNonQuery();
}
//try connect
if (triesToConnect <= 0)
return;
//sometimes on slow servers (hosting) there could be situations when database requires some time to be created.
//but we have already started creation of tables and sample data.
//as a result there is an exception thrown and the installation process cannot continue.
//that's why we are in a cycle of "triesToConnect" times trying to connect to a database with a delay of one second.
for (var i = 0; i <= triesToConnect; i++)
{
if (i == triesToConnect)
throw new Exception("Unable to connect to the new database. Please try one more time");
if (!DatabaseExists())
Thread.Sleep(1000);
else
break;
}
}
/// <summary>
/// Checks if the specified database exists, returns true if database exists
/// </summary>
/// <returns>
/// A task that represents the asynchronous operation
/// The task result contains the returns true if the database exists.
/// </returns>
public virtual async Task<bool> DatabaseExistsAsync()
{
tryView on GitHub (pinned to 64bdf2ff08)
Solutions
- Increase the triesToConnect value passed to CreateDatabase so the loop tolerates slow provisioning.
- Verify the SQL Server instance is up and the account can connect to the 'master' database (test with DatabaseExists before installing).
- Check the server name, port, and credentials in the install connection string; confirm port 1433/firewall allows the app host.
- Pre-create the database manually and re-run installation, or simply retry the installer once the server is responsive.
Example fix
// before dataProvider.CreateDatabase(dbName, triesToConnect: 5); // after dataProvider.CreateDatabase(dbName, triesToConnect: 30);
Defensive patterns
Strategy: retry
Validate before calling
// Pre-flight: confirm server reachable and creds valid before install
if (!dataProvider.DatabaseExists())
throw new InvalidOperationException("Cannot reach SQL Server; check connection string before creating the database."); Try / catch
try { dataProvider.CreateDatabase(dbName, triesToConnect: 30); }
catch (Exception ex) when (ex.Message.Contains("Unable to connect to the new database"))
{ /* log, verify server/creds/port 1433, then retry install once server is responsive */ } Prevention
- Test the connection to 'master' and verify CREATE DATABASE permission before installing.
- Use a generous triesToConnect on slow/shared hosting.
- Confirm port 1433/firewall egress from the app host.
When it happens
Trigger: Installation flow calling dataProvider.CreateDatabase(databaseName, triesToConnect) where the SQL Server instance is slow to materialize the new database, the SQL Server service is under load, disk I/O is saturated, or the connection string points at a server that cannot authenticate/open the new catalog in time.
Common situations: Shared hosting where CREATE DATABASE is throttled; SQL Server Express with slow spinning disks; low triesToConnect default; wrong server name/credentials making DatabaseExists always return false; firewall blocking port 1433 so the DB is never reachable.
Related errors
- Unable to connect to the new database. Please try one more t
- Unable to connect to the new database. Please try one more t
- This database provider does not support backup
- This database provider does not support database shrinking.
- Data provider supports connection only with login and passwo
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/ec0cd0d535399988.
Report an issue: GitHub.