Can not connect remotely to a second instance of SQL Server 2016 - sql-server

In a server I have 2 instances, the first that is the default called SQLCompart on TCP port 1433 and the second called AISLANTES on TCP port 1435.
When I try to connect remotely to SQLCOMPART it works successfully, but just with the ip (it doesn't connect with named instance <IP>\<INSTANCE>).
So the problem here is that I can't connect remotely to AISLANTES.
I am trying with <IP>, <PORT> also with <IP>\<INSTANCE> and with <IP>\<INSTANCE>, <PORT>
The firewall inbound rule for tcp port 1435 is enabled.
What am I missing?
SQL Server Configuration Manager
SQL Server Configuration Manager TCP/IP properties
this is the error that i get
SQL SERVER MANAGEMENT STUDIO
SQLCMD

Possible reasons:
Port was changed, but instance was not restarted
Multiple firewalls and port 1435 is not opened on all of them
TCP for a second instance not enabled at all
Consider to check your latest SQL Server log and find something like:
2018-04-09 18:53:11.95 spid11s Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\MSSQLSERVER ].
2018-04-09 18:53:11.95 spid11s Server local connection provider is ready to accept connection on [ \\.\pipe\sql\query ].
2018-04-09 18:53:11.97 Server Server is listening on [ ::1 <ipv6> 1434].
2018-04-09 18:53:11.97 Server Server is listening on [ 127.0.0.1 <ipv4> 1434].
So you will know for sure on which port SQL Server listens for incoming connections
p.s. if SQL instance installed on domain controller, it cannot use NETWORK_SERVICE as an account

Related

SQL server - Client Connection works in one network not on another

We cannot access from a client computer (Client) to a SQL Server computer (Server) on network A but successfully on another B. The Server computer has SQL Server 2019 installed, the Client computer has SQL Native Client 11.0 installed. We can connect from this client to the server in on network A either using sqlcmd, udl interface, or Telnet. But on a different network B, we cannot connect from the same Client to the same Server! What network configuration can avoid a SQL Server connection?
Server Parameters:
1. We defined firewall rules to allow inbound connection on ports 1433 for TCP and 1434 for UDP. We verified that that is the case on the Server by using "netstat -aon". We disabled the Norton Smart Firewall.
2. We have set this rule to apply to all profiles: Domain, Public, Private.
3. We ensured that all protocols for SQLEXPRESS are allowed and enabld in the SQL Server Configuration Manager, specifically TCP/IP.
4. We have enabled SQL Server Browser.
5. We have restarted all services multiple times after our configuration changes. We have even restarted the machine.
6. We made sure that the Server is accessible remotely and using SQL Server Authentication.
7. We reset both the modem and the router for both Networks before testing.
8. We confirmed both the Computer and the SQL Instance names in the SMSS logins and logs.
Tests we did on Network A:
1. We can ping the Client from the Server, the Server from the Client both with IP addresses and computer names (On Server: "ping -a ClientIP/ComputerName", On Client: "ping -a ServerIP/ComputerName". Both results with "Reply...").
2. We can access the database in the Server using SSMS both with Windows Authentication and SQL Server Authentication.
3. We cannot access to Server from the Client by Windows Authentication either by using "sqlcmd -S Server\sqlexpress -E".
4. We cannot access to Server from the Client by SQL Server Authentication by using "sqlcmd -U User -P Password -S Server\SQLExpress".
On the other hand, when these computers are in Network B, without changing anything we can connect to Server from the Client.
Here are the error messages we get:
sqlcmd -U User -P Password -S Server\SQLExpress
By default named instances use dynamic ports, which you're not allowing through the firewall.
The best solution is probably to simply configure the SQL Server instance to listen on the fixed port 1433, then you don't need to use an Instance Name or explicit port to connect.
To do this us SQL Server Configuration Manager to configure the instance to listen on port 1433 on all IPs. It should look like this:
With Dynamic Ports blank, and 1433 in the TCP IP port.
Then restart the SQL Server instance and in the SQL Server Logs you should see a message like
Server is listening on [ 'any' <ipv4> 1433].
Then try to connect like
sqlcmd -U User -P Password -S Server
And you can test with Powershell
PS C:\> test-netconnection Server -port 1433
If you do this you won't need the SQL Browser Service or the firewall rule for port 1434.

Can't connect to MS SQL Server on network

SQL server does not seem to be communicating. Port 1433 is open. SQL Configuration Manager used to turn on port 1433. SQL Management Studio used to turn on communications. "NETSTAT -an" on the server shows nothing listening on port 1433. Any ideas?
SQL Configuration Manager

Connect to SQL Server 2016 via Putty/SSH

I have an SSH tunnel established to my Server using Putty. I have set up two tunnels:
L3407 => 192.168.100.107:3389
L31433 => 192.168.100.107:1433
I can successfully RDP into the server using "localhost:3407". However, when I open SSMS and try using "localhost,31433" it won't connect. The error I get reads:
"A network-realted or instance-speciffic error occured while establishing a connection to SQL Server. The server was not found or was not accessible. Verify the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The remote computer refused the network connection.) (Microsoft SQL Server, Error: 1225)"
I've verified that TCP/IP is turned on in SQL Server Configuration Manager, and the IP addresses are setup. I have checked the logs on the SQL Server, and I have:
- Server is listening on [127.0.0.1 <ipv4> 1434]
- Server is listening on [::1 <ipv6> 1434]
- Server is listening on ['any' <ipv4> 1433]
- Server is listening on ['any' <ipv6> 1433]
I can connect to SSMS on the server using the machine name (named pipes),(LOCAL), localhost, 192.168.100.107, or the public IP. And if I open a hole in the Firewall for port 1433, then I can connect locally using ":1433". (Of course I almost immediately start seeing hacking attempts, so it has to be turned right back off.)
Based on the error I would think that the server is blocking it somehow, but the local Firewall is off and the hardware Firewall logs no attempts for RDP or SSMS (as expected, since it is going through the tunnel).
I am lost on what else to try. Anyone have any ideas?

SQL network-instance related issue (with error 258)

I get the following message when trying to connect to SQL database from a remote machine using MS Management Studio with Server Name [ XX.XXX.XXX.XXX,1433\MyServerName ] and SQL authentication:
Cannot connect to XX.XXX.XXX.XXX,1433\MyServerName.
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: TCP Provider, error: 0 - The wait operation timed out.) (Microsoft SQL Server, Error: 258)
The wait operation timed out
I have done the following:
Allowed remote connection in Server Properties window in SQL Management Studio
Configured server machine to have static IPv4/DNS addresses.
Enabled TCP/IP in SQL Configuration Manager (in SQL Server Network Configuration)
In TCP/IP properties, adjusted [ Protocol -> Listen All -> No ] & set IP[1-8] to TCP port 1433 and IPAll port to 1433 (TCP dynamic ports left blank)
Set Inbound/Outbound enable connection (Domain, public, private) rules in Windows Firewall for ports TCP 1433, UDP 1434 (should make no difference, since port is specified), service executables: sqlbrowser.exe in C:\Program Files (x86)\Microsoft SQL Server\90\Shared (not used I think because port is specified) and sqlservr.exe in C:\Program Files\Microsoft SQL Server\MSSQL13.MyServerName \MSSQL\Binn
Set NAT actions in server-side router for ports 1433 (TCP), 1434 (UDP) (again, should not matter) to server's local IPv4 address and ports 1433, 1434 accordingly.
Made sure SQL service is running, ports are open and listening on server machine.
I can connect to the database on server machine using Windows or Sql credentials with either PC name, or machine's local IPv4.
Interesting thing is, when >telnet XX.XXX.XXX.XXX 1433 is run, it takes about 10-12 seconds to fail (Could not open connection to the host, on port 1433: Connect failed), but I can see the 2 packets coming to the router itself. Same with the login using SQL Manager - packets come to the router, but either server machine refuses (doesn't resolve?) the connection, or it doesn't even get to the machine.
Appreciate your suggestions.
Versions used:
MS SQL Server 2016 Express, MS SQL Management Studio 17, SQL Server 2016 Configuration Manager, Windows 10 Pro.
Have you tried telnet on 1433 locally?
Are you sure your local connection is using TCP/IP? By default, local connections use DBNMPNTW (named pipes) which uses shared memory on the back end for local connections and is faster than TCP/IP.
When SQL Server is working correctly on TCP/IP telnet will connect and leave you blinking waiting for protocol-- it doesn't hang for 10-12 seconds and fail.
If telnet works locally but not remotely, then you know the problem is in the networking layer (firewall, NAT, routing, etc.). If it does not, then the problem is in the SQL configuration setup. Did you restart the service after changing the connection settings?

Remote connect to SQL Server Standard Edition from PHP/FreeBSD

Unable to connect to our company MSSQL server from one of our FreeBSD servers.
# telnet 192.168.1.51 1433
Trying 192.168.1.51...
telnet: connect to address 192.168.1.51: Connection refused
telnet: Unable to connect to remote host
No firewall running on the MSSQL server, and i have opened the default port on the BSD-FW
00210 allow tcp from any to any dst-port 1433 in
00215 allow tcp from any to any dst-port 1433 out
Any ideas on this?
The specifics of the MSSQL server running on a Windows Server 2003
Test whether you can connect from another non-local machine. If not TCP connections may not be enabled for SQL Server. Here are instructions for enabling TCP/IP Connections with SQL Server 2000
I updated it MSSQL to Service Pack 4, and i'm now able to telnet to the server on the specified port. And also connect to the server from PHP with pdo_dblib

Resources