Vscode-mssql: Can't connect to local server

Created on 15 Mar 2018  路  4Comments  路  Source: microsoft/vscode-mssql

Steps to Reproduce:

  1. I've followed these tutorials
    https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker
    https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-develop-use-vscode#connect-to-sql-server
    2/ I am using asp.net core
    I am getting this error
System.Data.SqlClient.SqlException (0x80131904): 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. (provider: TCP Provider, error: 35 - An internal exception was caught) ---> System.AggregateException: One or more errors occurred. (Connection refused [::1]:1433) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused [::1]:1433 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 

Things I have tried
1/ I can connect to the local server using sqlcmd
2/ Turn off the firewall
3/ Make sure Docker is using at least 4gb of rams

enhancement

Most helpful comment

I had the same issue. As it turned out I had to use a comma before the port number (instead of a colon) for the connection string.

I'm not sure why this detail was missed in the tutorial.

All 4 comments

Thanks for the report. I can't reproduce this yet.

To clarify, when you say that you can connect using sqlcmd, do you mean by following the "Connect from outside the container" instructions or by connecting from within docker?

Make sure you're specifying the port number when you set up the connection in vscode-mssql. If you're following the docker quick start instructions that you linked exactly, you'll need to enter localhost,1401 as the server hostname in VS Code since it exposes the server on port 1401.

I had the same issue. As it turned out I had to use a comma before the port number (instead of a colon) for the connection string.

I'm not sure why this detail was missed in the tutorial.

localhost,1401 works for me

Glad to hear it works. I'll leave this open as a suggestion to make the more common localhost:1401 syntax work too, and will take a look at updating the docs to mention this

Was this page helpful?
0 / 5 - 0 ratings