question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue connecting to MS SQL Server running on non default port 1433

See original GitHub issue

@mahesji commented on Fri Feb 09 2018

Issue Title

Issue connecting to MS SQL Server running on non default port 1433 from Linux environment

OS Version Linux 4.4.0-109-generic #132~14.04.1-Ubuntu SMP Tue Jan 9 21:46:42 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

dotnet core project settings

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
    <PackageReference Include="System.Data.SqlClient" Version="4.4.2" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
  </ItemGroup>

</Project>

General

Using System.Data.SqlClient to connect to Sql server database. Following the sample in this post https://blogs.msdn.microsoft.com/dotnet/2016/11/09/net-core-data-access/

It works fine if the sql server is listening on port 1433 but fails when connecting to sql servers listening on port 1434. Confirmed that there is no network / firewall issues that that is blocking the ports. Able to connect to the same sql server on port 1434 using java code. This connection string works > Server=myhostname,1433;Database=mydatabase;User Id=myuser;Password=mypassword; This connection string does not work in above linux environment. Works fine on windows Server=myhostname,1434;Database=mydatabase;User Id=myuser;Password=mypassword;

Both connect strings work fine in Windows environment.

Record Fetch Error: 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)


@usergiga commented on Fri Feb 09 2018

If an instance of SQL Server is listening on any other port, than 1433. You have to specify a server-alias or change the standard port globally. You can have SQL Server listening on multiple ports.


@mahesji commented on Mon Feb 12 2018

@usergiga , Thank you for the reply. I have the alias created and that doesn’t seem to help. The connection works fine in Windows runtime. Have this issue only in the Linux (Ubuntu) runtime.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arthurvaverko-kalturacommented, Oct 8, 2019

Thanks @cheenamalhotra,

Looks like latest nuget package works fine. Now we have some issues under load tests. Seems like linux libs are handling connections less efficiently than windows.

We get tcp connection establishment timeouts after a certain load has been achieved.

The effect does not end with sql … same issues starts with any other outbound network communications like rabbit mq and basic http requests…

Still investigating root cause.

1reaction
saurabh500commented, Feb 21, 2018

@mahesji have you confirmed that the TCP connectivity from Linux to the port is working fine? Also have you tried specifying the IP address of the server instead of the host name in the connection string. To find out if the TCP port on the Windows server can be connected to, from linux or not, use nc -vz hostname port (assuming you have netcat installed on the linux host)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure SQL Server to listen on a specific TCP port
In the console pane, select SQL Server Services. In the details pane, right-click SQL Server (<instance name>) and then select Restart, to stop ......
Read more >
Issue connecting to MS SQL Server running on non default ...
If an instance of SQL Server is listening on any other port, than 1433. You have to specify a server-alias or change the...
Read more >
Connection to SQL Server on non standard port using SSMS
Make sure TCP Dynamic Ports is blank and that TCP Port is set to 1433 (or whatever you want to set TCP Port)....
Read more >
Not listening SQL Server Port 1433 - Microsoft Q&A
I already installed MS SQL server Standard Version in my Window Server 2016 , After that can not connected from outside.
Read more >
The MS-SQL server does not answer
If the port 1433 is closed, an error will be returned immediately. If the port 1433 is open, you will be able to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found