SQL Server Connection Troubleshooting
This guide helps resolve common SQL Server connection problems on Windows hosting.
Issue 1: Cannot Connect from Application
Verify Connection String:
// Correct format for shared hosting: Server=YOURSERVER\YOURINSTANCE;Database=YOURDBNAME;User Id=YOURUSER;Password=YOURPASSWORD; // Or using integrated port: Server=sql.yourhost.com,1433;Database=YOURDBNAME;User Id=YOURUSER;Password=YOURPASSWORD;
Common Connection String Mistakes:
- Using
localhostinstead of actual server name - Missing instance name after backslash
- Wrong database name (case-sensitive)
- Incorrect username or password
Find Your Connection Details:
- In Plesk, go to Websites & Domains
- Click Databases
- Click on your database name
- Connection info is displayed under "Connection Information"
Issue 2: Cannot Connect from SSMS (SQL Server Management Studio)
Remote Connections:
Important: Remote SQL connections may require:
- IP address whitelisting by support
- Correct external connection details
- TCP/IP protocol enabled
SSMS Connection Settings:
- Server type: Database Engine
- Server name: Use hostname provided by your host
- Authentication: SQL Server Authentication
- Login: Your database username
- Password: Your database password
Issue 3: Login Failed Errors
"Login failed for user" Messages:
| Error | Cause | Solution |
|---|---|---|
| Login failed for user 'X' | Wrong credentials | Reset password in Plesk Databases |
| User does not have access to database | Permission issue | Verify user is assigned to database |
| Cannot open database | Database doesn't exist or offline | Check database exists in Plesk |
Reset Database User Password:
- In Plesk, go to Databases
- Click User Management
- Select the user and change password
Issue 4: Timeout Errors
Connection Timeout:
// Increase timeout in connection string: Server=YOURSERVER;Database=YOURDB;User Id=USER;Password=PASS;Connection Timeout=30;
Command Timeout (for long queries):
// In C#: command.CommandTimeout = 120; // 120 seconds // In connection string: Command Timeout=120;
Issue 5: Database Size/Space Issues
Check Database Size in Plesk:
- Go to Databases
- Size is shown next to each database
- Check against your plan's database size limit
Shrink Database (contact support):
If your database log file is large, contact support to:
- Shrink the log file (.ldf)
- Change recovery model if appropriate
- Set up log file size limits
Issue 6: Entity Framework Connection Issues
appsettings.json Configuration:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOURSERVER;Database=YOURDB;User Id=USER;Password=PASS;TrustServerCertificate=True;"
}
}
Common EF Core Issues:
- Add
TrustServerCertificate=Truefor self-signed certs - Add
Encrypt=Falseif encryption not configured - Verify migrations have been applied
Quick Troubleshooting Checklist
- ☐ Connection string format is correct
- ☐ Server/instance name is accurate
- ☐ Database name exists and is spelled correctly
- ☐ Username and password are correct
- ☐ User has access to the specific database
- ☐ Firewall allows connection (for remote access)
- ☐ Database is online and not over quota