My app won't connect to SQL Server while in diferent subnet - sql-server

I'm struggling to connect my app to a SQL server whitch is in another subnet. I'm using connection string like that:
192.168.2.xxx\nameOfTheInstance
and everything works fine from the same subnet, but if my PC has ip adress like 192.168.3.1/24 my app won't connect to the server. Oddly, when i use the same exact connection string in ssms in the same PC configuration, it works perfectly well.
We've eliminated network specific errors, so it has to Windows Firewall or some server setting that i don't know of.
Server is Windows Server 2019 (1809) on a phisical machine, and client can be literaly every Windows PC.
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: SQL Network Interfaces, error: 26 -
Error Locating Server/Instance Specified)

Never mind. SQL server browser was answering from second nic. Problem solved.

Related

I Can Connect to my SQL Server Instance through SQL Server Management and through SQL Profiler, but my VS App Will Not Connect

Lucky me, I got to work from home due to the COVID-19 outbreak. However, now when I try to use Visual Studio 2019 to run my app, NHibernate always fails from not finding my SQL Server instance.
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I then tried to connect to my test database through SQL Server Management Studio and it worked. I have no clue why one worked and the other didn't. I don't even know where to trouble shoot this issue, I know programming, but very little about setting up a server and networking. My guess is that it's something with me no longer being on our domain anymore, but why would this affect my local instance?
I tried letting SQL Server through the firewall, I checked to make sure remote connections are allowed. I also tried connecting with my local IP instead of with localhost, using just localhost, or even just (local) and none of that worked. I'm just completely lost otherwise.
Edit:
My connection string:
Data Source=localhost\SQLEXPRESS;Initial Catalog={0};Integrated Security=True;
How I connect via SQL Server Management Studio:

IIS can't connect to SQL Server using SQL Server authentication

I have a very strange problem that I have tried to figure out for some time now but unsuccessfully. At work I am using a laptop for development. We have our application run locally on each developer's laptop, but we all use the same dev database. So when I take my work laptop home and connect it to our vpn, my laptop's IIS connects to SQL Server and everything works just fine.
The problem is when I try to use my personal desktop for work I connect it to the same vpn I connect my laptop to run the same code that is on the laptop with the same connection strings, but IIS can't connect to SQL Server and I get this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
On both computers I am able to connect to SQL Server using SSMS with no problem. On both computers I can run Integration Tests that hit the database just fine (integration tests use the exact same connection string that the application is using), but if I try to run the application it can't connect. I have tried changing all sorts of settings in IIS but to no avail.
Thanks for your help in advance.
Make sure SQL Server Service is running
If a named instance, make sure SQL Server browser service is running
Make sure SQL Server is configured to allow remote connections
Examine the SQL Server error log for messages confirming that SQL is listening on the expected network interfaces and ports
Test server connectivity with PING from the client machine
Test port connectivity using TELNET or PowerShell to the server and port (from step 4) from the client machine. For example
a. TELNET 1433
b. PowerShell: 1433 | % { echo ((new-object Net.Sockets.TcpClient).Connect("YourServerName",$)) "server listening on TCP port $" }
Check firewall settings if step 5 or 6 connectivity test fails

Unable to connect SQL Server from a PC while it is accessed from other PC

I try to search my problem and found lots of threads, but all of them server related. All suggestion/tips regrading Database server related.
I have a database server (SQL Server 2014) hosted on VPS. Server is running fine without any issue, and working fine from all computer over internet. But from one PC it is not connecting. I disabled antivirus, added program on exception list on firewall,but still I am unable to connect the server, while that server are access from other PC. This PC connecting on internet through cable internet connection and operating system is Windows 7 Ultimate (I called service provider, and confirmed that they are not blocking/filtering any IP).
Thanks in advance.
Error Details:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

A network-related or instance-specific error while trying to connect to SQL Azure from SSMS

I get the following error when I am trying to connect to SQL Azure account from My SQLServer Management studio. I use "SQL Server 2008 R2" on Windows 7 32-bit machine.
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 Named
Pipes Provider, error 40 - Could not open a connection to SQL Server)
I have followed the instructions from blog.sqlauthority.com but it did not help.
This is how am trying to connect to my Azure:
And I have noticed one more error in SQL Server Services, But all the services are running.
The remote procedure call failed. [0x800706be]
PS: I have also added my IP address in the "Manage IP Addresses" in windows azure.
Any ideas!
This is a very generalized question. There can have many reasons due to which you are getting this network related error.
Have you ever got it work before? Are you sure server name is correct? Can you cross check?
Or else you can check the internet connectivity and working of VPN(if you use it)

SQL Server 2005 Remote Connection ( Over Internet )

I have installed SQL Server 2005 in mixed mode.
I am able to connect to Database "locally" i.e.
(Server-name/Instance or internal-ip/Instance) using both kinds of Authentication.
I have configured SQL Server for remote connection by following below steps
Steps:
Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer.
Turn on the SQL Server Browser service.
Configure the firewall to allow network traffic that is related to SQL Server and to the SQL Server Browser service. Ref: http://support.microsoft.com/kb/914277#method3
In addition, I have turned off my firewall.
I am able to ping my computer through the External IP.
But when it comes to connecting to sql server, its giving the error.
"TITLE: Connect to Server
Cannot connect to <ip address>\SQLEXPRESS.
ADDITIONAL INFORMATION:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
Please help me,
I have referred many article and tested all possible solution, but nothing seems to be working for me.
It turned out to be an issue with Port Forwarding from my Modem/Router to respective Machine IP.
To resolve this issue, I just configured my Router so that it can accept the request on some specific port [External IP:port_number] and then map that request to my machine's [Internal IP:port_number] as multiple computers were connected to a single router.
Also, please make sure that Firewall on your server is configured correctly to accept the inbound network traffic on that specific port.

Resources