Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
trustieee opened this issue Jan 9, 2024 · 1 comment

Comments

@trustieee
Copy link

trustieee commented Jan 9, 2024

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

@jreyesco16
Copy link

I have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants