If you’ve ever renamed your Windows laptop or PC and then found yourself locked out of SQL Server, you’re not alone. Here’s what happened and how to fix it — including the SSL certificate issue that trips up most people.
The Problem
SQL Server registers your machine name at install time. When you rename the machine, SQL Server still thinks it’s the old name. You’ll see errors like:
- “Cannot connect to OLDNAME”
- “The server was not found or was not accessible”
- “The certificate chain was issued by an authority that is not trusted”
Step 1: Update the Server Name in SQL Server
First, connect using localhost — that still works regardless of the machine name.
Open SSMS, connect to localhost, and run:
-- Confirm the mismatch
SELECT @@SERVERNAME -- returns old name
SELECT SERVERPROPERTY('MachineName') -- returns new name
-- Fix it
sp_dropserver 'OLDNAME'
GO
sp_addserver 'NEWNAME', 'local'
GO
Replace OLDNAME and NEWNAME with your actual values. Then restart the SQL Server service via Services.msc.
Step 2: Create a New SSL Certificate
SQL Server’s self-signed certificate was issued for the old machine name. You’ll need a new one.
Run this in PowerShell as Administrator, replacing NEWNAME with your machine name:
New-SelfSignedCertificate -DnsName "NEWNAME" `
-CertStoreLocation "cert:\LocalMachine\My" `
-FriendlyName "SQL Server NEWNAME" `
-KeyUsage KeyEncipherment `
-NotAfter (Get-Date).AddYears(10)
Note the thumbprint in the output — you’ll need it in the next step.
Step 3: Grant SQL Server Access to the Certificate
SQL Server runs as a service account and needs permission to read the certificate’s private key. Run this in PowerShell as Administrator, replacing the thumbprint with yours:
$cert = Get-Item "cert:\LocalMachine\My\YOUR_THUMBPRINT_HERE"
$rsaKey = [System.Security.Cryptography.X509Certificates.RSACertificateExtensions]::GetRSAPrivateKey($cert)
$keyPath = "$env:ALLUSERSPROFILE\Microsoft\Crypto\Keys\" + $rsaKey.Key.UniqueName
$acl = Get-Acl $keyPath
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("NT Service\MSSQLSERVER", "Read", "Allow")
$acl.AddAccessRule($rule)
Set-Acl $keyPath $acl
Step 4: Assign the Certificate in SQL Server Configuration Manager
- Open SQL Server Configuration Manager
- Navigate to SQL Server Network Configuration > Protocols for MSSQLSERVER
- Right-click > Properties > Certificate tab
- Select the new certificate from the dropdown
- Click OK and restart SQL Server
Step 5: Trust the Certificate on Your Machine
Since it’s self-signed, Windows won’t trust it by default. Add it to the Trusted Root store:
$cert = Get-Item "cert:\LocalMachine\My\YOUR_THUMBPRINT_HERE"
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("Root", "LocalMachine")
$store.Open("ReadWrite")
$store.Add($cert)
$store.Close()
Done
You should now be able to connect to SQL Server using your new machine name in SSMS without any SSL warnings or trust errors.

