After a default installation, SQL Server accepts connections only from the machine it runs on: the Shared Memory protocol is enabled, TCP/IP is not, and Windows Firewall blocks port 1433 anyway. The moment an application server, a developer's SSMS or a reporting tool on another machine tries to connect, it fails with one of a handful of famous error numbers. This guide enables remote access the right way on a hosted Windows server: TCP/IP in Configuration Manager, a static port, a firewall rule scoped to the addresses that need it, SQL Browser only where a named instance makes it necessary, and TLS on the wire. It also decodes errors 26, 40, 53 and 18456 so you fix the layer that is broken rather than reinstalling. The steps are the same on a self-managed Windows VPS and on a server someone else operates; on MassiveGRID's managed SQL Server hosting the firewall is part of the hardening MassiveGRID applies, and you ask support to allow your application's address.
How a remote connection reaches SQL Server
A client connecting to sqlserver.example.com has to pass four gates, and every connection error maps to one of them:
- Name resolution and routing. The hostname must resolve to the server's address and a route must exist. Failures here are error 53 and "A network-related or instance-specific error" (error 40 on older clients).
- Windows Firewall. The server's firewall must allow the inbound TCP port. A blocked port looks like a timeout from the client's side.
- The SQL Server network protocol. The Database Engine must have TCP/IP enabled and be listening on the port the client used. For a named instance with a dynamic port, the client first asks the SQL Browser service on UDP 1434 which port to use; if Browser is stopped or blocked you get error 26.
- Authentication. Once the TCP session is up, the login must succeed. Failures here are error 18456, with a state number that says why.
Work the gates in order. A good habit on the client is Test-NetConnection sqlserver.example.com -Port 1433 in PowerShell: if TcpTestSucceeded is True the first three gates are open and any remaining error is authentication.
Step 1: enable TCP/IP and set a static port
Open SQL Server Configuration Manager (on Windows Server 2025 it is under SQL Server 2022 Configuration Manager in the Start menu, or run SQLServerManager16.msc). Under SQL Server Network Configuration > Protocols for MSSQLSERVER (or your instance name), right-click TCP/IP and choose Enable. Then open its Properties, go to the IP Addresses tab, scroll to IPAll, clear TCP Dynamic Ports and type 1433 (or a port of your choosing) into TCP Port. Restart the SQL Server service for the change to apply:
Restart-Service -Name MSSQLSERVER -Force
# named instance:
Restart-Service -Name 'MSSQL$SQLEXPRESS' -Force
Confirm the listener:
Get-NetTCPConnection -State Listen -LocalPort 1433 | Select-Object LocalAddress, OwningProcess
Or from inside SQL Server, which also tells you which protocol your own session used:
SELECT local_tcp_port, net_transport, protocol_type
FROM sys.dm_exec_connections WHERE session_id = @@SPID;
The same change in PowerShell, useful for a build script, uses the SQL Server WMI provider:
Import-Module SqlServer
$wmi = New-Object Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer
$tcp = $wmi.ServerInstances['MSSQLSERVER'].ServerProtocols['Tcp']
$tcp.IsEnabled = $true
$tcp.IPAddresses['IPAll'].IPAddressProperties['TcpDynamicPorts'].Value = ''
$tcp.IPAddresses['IPAll'].IPAddressProperties['TcpPort'].Value = '1433'
$tcp.Alter()
Static port or dynamic port?
A default instance listens on 1433 by default and clients find it with the server name alone. A named instance picks a random port at each start unless you fix one. Fixing a static port (1433 if there is only one instance, otherwise 1434 upward or any free port above 1024) is always the better choice on a server behind a firewall: the firewall rule stays valid, you do not need SQL Browser, and the connection string can carry the port explicitly as sqlserver.example.com,1433 (a comma, not a colon, in SQL Server client syntax).
Using a non-standard port is not a security measure, because a port scan finds it in seconds, but it does cut the volume of automated login attempts in the error log.
Step 2: the firewall rule, scoped to who needs it
Windows Server 2025 has the firewall on for every profile. Add an inbound rule for the port, and restrict it to the source addresses that will connect: your application server, your office or VPN address range, a CI runner. The PowerShell cmdlet accepts several addresses and CIDR ranges:
New-NetFirewallRule -DisplayName "SQL Server TCP 1433 (app servers)" `
-Direction Inbound -Protocol TCP -LocalPort 1433 `
-RemoteAddress 203.0.113.10, 198.51.100.0/24 `
-Profile Any -Action Allow
The classic netsh form is equivalent:
netsh advfirewall firewall add rule name="SQL Server TCP 1433 (app servers)" dir=in action=allow protocol=TCP localport=1433 remoteip=203.0.113.10,198.51.100.0/24
If you really must allow any source, for example a SaaS integration with a changing address pool, prefer a program rule bound to the SQL Server executable so only that process receives the traffic, and pair it with TLS and a strong login policy:
New-NetFirewallRule -DisplayName "SQL Server program rule" -Direction Inbound `
-Program "C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Binn\sqlservr.exe" -Action Allow
To check what you have:
Get-NetFirewallRule -DisplayName "SQL Server*" | Get-NetFirewallPortFilter
Get-NetFirewallRule -DisplayName "SQL Server*" | Get-NetFirewallAddressFilter
On a MassiveGRID server there is also the platform's DDoS protection in front of the VM, but that filters volumetric attacks, not individual TCP connections; the Windows Firewall rule is still what decides who can reach SQL Server. On the managed SQL Server host, the OS firewall is maintained by MassiveGRID's hardening and you request the allowed addresses through a ticket; on a self-managed Windows VPS running SQL Server the rule above is yours to write.
Step 3: SQL Browser, only for named instances without a fixed port
SQL Browser is a small service that answers "which port is instance X on?" over UDP 1434. You need it in exactly one case: a named instance that still uses dynamic ports and clients that connect by SERVER\INSTANCE without a port. If you fixed a static port in Step 1 and put it in the connection string, leave Browser disabled: it is one less service to expose, and UDP 1434 has been used in reflection attacks.
If you do need it, set the service to Automatic and open UDP 1434 to the same source addresses:
Set-Service -Name SQLBrowser -StartupType Automatic
Start-Service -Name SQLBrowser
New-NetFirewallRule -DisplayName "SQL Browser UDP 1434" -Direction Inbound -Protocol UDP -LocalPort 1434 -RemoteAddress 203.0.113.10 -Action Allow
SQL Server Express installs as the named instance SQLEXPRESS with Browser disabled, which is why "I installed Express and nothing can connect" is such a common question. The fix is either a static port plus server,port in the connection string, or enabling Browser.
Step 4: connect from SSMS and from an application
In SSMS, the Server name field takes any of these forms:
| Server name | Means |
|---|---|
sqlserver.example.com | Default instance on TCP 1433 |
sqlserver.example.com,1533 | Any instance on a fixed port 1533, no Browser needed |
sqlserver.example.com\SQLEXPRESS | Named instance, port looked up through SQL Browser on UDP 1434 |
tcp:sqlserver.example.com,1433 | Force the TCP protocol, useful when a local alias or Shared Memory is interfering |
For applications the equivalent connection string is:
Server=tcp:sqlserver.example.com,1433;Database=shop;User ID=shop_app;Password=...;Encrypt=True;TrustServerCertificate=False;
Two things changed in the Microsoft drivers in recent years and trip up migrations: Microsoft.Data.SqlClient 4.0 and later, and ODBC Driver 18, default to Encrypt=True, and they validate the server certificate. If the server still has the self-signed certificate SQL Server generates at start-up, the client fails with "The certificate chain was issued by an authority that is not trusted". The correct fix is to install a certificate the client trusts (next section); the quick fix for a test server is TrustServerCertificate=True, which keeps encryption but skips validation.
Create a login for the application that owns only what it needs, rather than using sa:
CREATE LOGIN shop_app WITH PASSWORD = 'a-long-random-password', CHECK_POLICY = ON;
USE shop;
CREATE USER shop_app FOR LOGIN shop_app;
ALTER ROLE db_datareader ADD MEMBER shop_app;
ALTER ROLE db_datawriter ADD MEMBER shop_app;
Step 5: encrypt the connection and tighten authentication
Once 1433 is reachable from another network, the traffic should be encrypted and the logins hard to guess.
- Certificate. Request a certificate for the server's DNS name (a Let's Encrypt certificate works, through win-acme or Certify The Web), import it into the Local Machine > Personal store, grant the SQL Server service account read permission on its private key, and select it in Configuration Manager under SQL Server Network Configuration > Protocols > Properties > Certificate. Set Force Encryption to Yes on the Flags tab and restart. From then on every connection is TLS, and clients with Encrypt=True validate the name.
- Windows authentication where you can. A domain or local Windows account never sends a password over the connection and is covered by the account lockout policy. For applications on the same server, use it.
- SQL logins with policy.
CHECK_POLICY = ONapplies the Windows password policy to SQL logins;CHECK_EXPIRATIONis optional. Disable sa after you have your own sysadmin login:ALTER LOGIN sa DISABLE; - Audit failed logins. Server Properties > Security > Login auditing > Failed logins only writes every failure to the error log, which is how you notice a brute-force run against a port you thought was closed.
- Do not expose 1433 to the internet. If a developer at home needs access, use the hosting provider's VPN, a WireGuard tunnel to the server, or an SSH or RDP tunnel; connecting through RDP and running SSMS on the server is also fine. The RDP hardening guide covers the same ideas for the remote desktop port.
The errors, decoded
| Error | What the client says | What is actually wrong | Fix |
|---|---|---|---|
| 53 | "Named Pipes Provider: Could not open a connection to SQL Server" | The hostname did not resolve, or the server is unreachable, or the port is blocked and the client fell back to Named Pipes | Check DNS and routing, run Test-NetConnection on the port, review the firewall rule's RemoteAddress |
| 40 | "A network-related or instance-specific error occurred... Could not open a connection" | TCP/IP disabled, service stopped, wrong port, or firewall blocked | Enable TCP/IP, confirm the listener with Get-NetTCPConnection, confirm the service is running, confirm the port in the connection string |
| 26 | "Error Locating Server/Instance Specified" | You connected by SERVER\INSTANCE and the client could not reach SQL Browser on UDP 1434, or Browser is stopped | Use server,port with a static port, or start Browser and open UDP 1434 |
| 18456 | "Login failed for user" | TCP is fine; authentication failed. State 5 means the login does not exist, state 7 the login is disabled, state 8 wrong password, state 38 the default database is unavailable, state 58 the server is in Windows-only mode and you used a SQL login | Read the state in the SQL Server error log (the client only sees state 1), then fix the login, the mode or the default database |
| 10060 / 10061 | "TCP Provider: A connection attempt failed" or "actively refused" | 10060 is a timeout (firewall drop); 10061 means the server answered that nothing listens on that port | 10060: firewall; 10061: wrong port or TCP/IP not enabled |
| Certificate chain not trusted | "The certificate chain was issued by an authority that is not trusted" | New drivers default to Encrypt=True and the server has a self-signed certificate | Install a trusted certificate, or TrustServerCertificate=True on a test server |
The error log is at C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG or in SSMS under Management > SQL Server Logs. For 18456 in particular, the state number in the log is the whole answer.
Frequently Asked Questions
Should SQL Server listen on port 1433 or a custom port?
Either, as long as it is a static port written into the firewall rule and the connection string. Port 1433 is the convention for a default instance and keeps connection strings short; a custom port reduces log noise from automated scans but does not add security. Named instances should always get a static port so that SQL Browser and UDP 1434 are not needed.
Is it safe to open port 1433 to the internet?
No. Scope the firewall rule to the IP addresses of your application servers and your office or VPN, force TLS with a trusted certificate, use Windows authentication where possible, and audit failed logins. For individual remote users, connect through a VPN or tunnel, or run SSMS on the server over RDP.
Why can I connect locally but not from another machine?
A default installation has TCP/IP disabled and relies on Shared Memory, which only works on the same machine. Enable TCP/IP in SQL Server Configuration Manager, set a static port, restart the service and add a Windows Firewall rule for that port. If you connect by SERVER\INSTANCE, also start SQL Browser or switch to server,port.
What does login failed error 18456 state 1 mean?
State 1 is what the client is shown for every authentication failure, for security. The real state is in the SQL Server error log on the server: state 5 is an unknown login, 7 a disabled login, 8 a wrong password, 38 a default database the login cannot open, and 58 a SQL login used against a server in Windows-only authentication mode.
Who manages the firewall on MassiveGRID SQL Server hosting?
On the Managed Cloud Dedicated Server behind the SQL Server hosting page, MassiveGRID configures and maintains the Windows Firewall as part of the hardening and you request the allowed source addresses by ticket. On a self-managed Windows VPS or Windows Dedicated VPS, the firewall rules are yours.
A SQL Server host with the firewall maintained for you
MassiveGRID SQL Server hosting runs on a Managed Cloud Dedicated Server with Windows Server Standard and SQL Server Web licensed per vCore, from $86.34 a month for 2 reserved vCores, 8 GB and 128 GB NVMe. MassiveGRID hardens the OS, maintains the firewall, patches, backs up daily and monitors around the clock in New York, London, Frankfurt or Singapore.
See SQL Server hostingFurther Reading
- Microsoft Learn: Configure a server to listen on a specific TCP port
- Microsoft Learn: Configure the Windows Firewall to allow SQL Server access
- Microsoft Learn: Configure SQL Server Database Engine for encrypting connections
- Microsoft Learn: MSSQLSERVER_18456 and its states
- Microsoft Learn: Troubleshoot SQL Server connectivity errors