MSSQL connection in Visual Studio Mac->(Socket Exception)

moialbla 5 Reputation points
2025-05-03T20:21:38.7133333+00:00

HI Community!

I am facing the following problem and it is driving me crazy. I was creating a SQL Server in Azure, and I was trying to connect via Visual Studio Code, but using the exactly same configuration n Mac I am getting this error

User's image

System.Net.Sockets.SocketException (22): Invalid argument at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName) at Microsoft.Data.SqlClient.SNI.SNITCPHandle.Receive(SNIPacket& packet, Int32 timeoutInMilliseconds) at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() at Microsoft.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(SqlConnectionEncryptOption encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable, Boolean& fedAuthRequired, Boolean tlsFirst, String serverCert) at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnectionString connectionOptions, Boolean withFailover) at

Mac Specifications

Hardware Overview:

  Model Name: MacBook Pro

  Model Identifier: MacBookPro18,1

  Chip: Apple M1 Pro

  Total Number of Cores: 10 (8 performance and 2 efficiency)

  Memory: 16 GB

  System Firmware Version: 11881.101.1

  OS Loader Version: 11881.101.1

Software:

System Software Overview:

  System Version: macOS 15.4.1 (24E263)

  Kernel Version: Darwin 24.4.0

User's image

However, if I am using my Windows laptop and having the same connection String I could connect it and create tables.. my question is.. WHY? I've been googling and I found this issue https://github.com/dotnet/runtime/issues/81378 but not answer :(. :(

Anybody can help me?

Thanks!

SQL Server Database Engine
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 75,721 Reputation points Moderator
    2025-05-04T16:43:11.13+00:00

    you appear to be having SSL issues. try trust server certificate. if this works, you probably have an expired signing certificate and need to update your CA certificates:

    https://learn.microsoft.com/en-us/azure/azure-sql/updates/ssl-root-certificate-expiring?view=azuresql

    also as Mac only supports tcp, there is no need for the tcp: on the server name.


  2. k3 0 Reputation points
    2025-05-07T12:01:30.3766667+00:00

    Not sure if this will work for you but worked for me. Dowload Azure Data Studio and then attempt to set up the connection there. You may need to enter your password a few times in some popups to allow ADS to access what it needs from your Macbook. Then if you try and set up the connection it might request something to do with the firewall which requires you to login. Then the connection should be successful, and mssql will work again in vscode too.

    (appreciate these are vague instructions - I'm no expert this just worked for me. Maybe if it works for you too you can provide more detailed instructions for the next person :) )

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.