I’m unable to connect to my local SQL Server instance using sqlcmd. Despite trying several troubleshooting steps, I’m still facing connection issues. Here’s the error I receive:
PS C:Usersit admin> sqlcmd -S localhost -U sa -P 123456 -Q "SELECT @@version"
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
PS C:Usersit admin>
Here are the steps I’ve already taken to resolve the issue:
Set Named Pipes to “running” from SQL Server Configuration Manager.
Confirmed that the SQL Server instance is running.
Checked that SQL Server services are running in Services (Win+R then ‘services.msc’).
Enabled TCP/IP protocols from SQL Server Configuration Manager.
Allowed remote connections from SSMS.
Turned off the firewall.
Confirmed that 123456 is the password for my SQL server for the sa login.
Despite these measures, the problem persists. I’m looking for any additional suggestions or insights that might help resolve this issue.
Syed Ahad Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.