A network-related or instance-specific error occurred while establishing a connection to SQL Server

Problem : 
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.Verify that the instance name is correct and that SQL Server is configured to allow remote connections.



Solution:-
Make sure your database engine is configured with all below options to accept remote connections

Step 1: 
  • Make sure that you are able to ping to DB server from your local hosts.
  • Make sure that you are able to telnet to DB server from your local hosts.
If not then get in touch with your network administrator to open port for DB server , so that you can connect to DB server from your local machine

Step 2: Check Database services is running or not.

T-SQL :
select servicename,last_startup_time,status_desc,startup_type_desc from sys.dm_server_services


GUI: -  
  • Open SQL server configuration manager 
  • Click on SQL server services




Step 3:  Check TCP/IP is enabled or not and which TCP/IP port it is using.

  •  Open SQL server configuration manager.
  •  Click on SQL server Network Configuration 
  •  Click on Protocol for MSSQLSERVER


If not enabled then enabled it.

How to check which port TCP/IP is using 

Right click on TCP/IP --> Properties--> IP address(Tab)   .. Look for IP All


TCP PORT :- The default instance of the SQL Server Database Engine listens on TCP port 1433
TCP Dynamic Ports: Named instances of the Database Engine and SQL Server Compact are configured for dynamic ports.


IF SQL instance is configured with named instance then try to connect to DB using port number

Step 4:
Check SSMS has allowed remote connection or not from DB server.

T-SQL:
Sp_configure

To Configure config_value & run_Value , execute Below

EXEC sys.sp_configure N'show advanced options', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sys.sp_configure N'remote access', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO

GUI:
  •  Connect to Instance
  •  In object explore right click on instance
  •  Go to Properties
  •  click on Connections

Enable check box to allow remote connections.



Step 5:

Check firewall has allowed connections or not for specific port
  • Open Windows firewall with advance security 
  • Check in Inbound / Outbound connection whether DB port has allowed connection or not.



If not, Then use belo link
  



No comments:

Post a Comment