Skip to content

Unable to open tcp connection with host 'localhost:1443': dial tcp 127.0.0.1:1443 #796

Open
@trustieee

Description

Describe the bug

Cannot connect to named MSSQL server running locally.

> unable to open tcp connection with host 'localhost:1443': dial tcp 127.0.0.1:1443: connect: connection refused

EDIT
This seems to only occur when trying to connect to my SQL Server instance running on Windows, from a go app running in WSL.

To Reproduce

I've tried various connection string formats:

str1 := "server=localhost,mssqlserver2022;port=61821;user id=sa;password=sa;database=FooDB"
str2 := "server=localhost,mssqlserver2022;port=1433;user id=sa;password=sa;database=FooDB"
str3 := "server=localhost/mssqlserver2022;user id=sa;password=sa;database=FooDB"
str4 := "server=localhost;user id=sa;password=sa;database=FooDB"
str5 := "server=localhost:1433;user id=sa;password=sa;database=FooDB"
str6 := "server=localhost\\mssqlserver2022:1433;user id=sa;password=sa;database=FooDB"
str7 := `server=localhost\mssqlserver2022:1433;user id=sa;password=sa;database=FooDB`

// try with sqlserver
connection, err := sql.Open("sqlserver", str)
// try with mssql
connection, err := sql.Open("mssql", str)

I have a C# app on the side which uses this connection string, and it succeeds:

await using var connection = new SqlConnection(
"""
persist security info=false;
server=localhost\mssqlserver2022;
initial catalog=FooDB;
user id=sa;
password=sa;
""");

I've tried import _ "github.com/microsoft/go-mssqldb" and import _ "github.com/denisenkom/go-mssqldb"

Expected behavior

It should connect

Further technical details

SQL Server v. 16.0.1105.1
Windows 10 Home

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions