Connect to SQL Server 2016 via Putty/SSH - sql-server

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?

Related

Connect IIS in DMZ to SQL Server on intranet

I'm trying to connect IIS which is running on a server in the DMZ to a SQL Server instance on the company intranet. But, I'm getting the following error:
An unhandled exception occurred while processing the request.
Win32Exception: Access is denied.
Unknown location
SqlException: 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)
Do I need specific ports opened up on one of the servers? Or is there something else I need to do?
Considering your SQL server is running, start with the networking. On which port is your SQL instance listening (default 1433)?
If you don't know, open the SQL Server Configuration Manager (on the SQL Server). Navigate to the SQL Server Network Configuration > Protocols for %instancename% > TCP/IP > IP Addresses. Then, test if something is blocking this connection; on your IIS in PowerShell:
Test-NetConnection -ComputerName sqlservername -Port 1433
If this doesn't work, check the Inbound Rules for Windows Firewall on your SQL Server. Make sure you work on the right network profile and eventually speak to the one managing your network systems in your company.
Maybe your IIS can't resolve the SQL Servers hostname? Try using the IP and check your DNS configuration.
There might also be something off with your connection string. Mind posting it here?

SQL Server has lost tcp/ip connectivity, works locally

An SQL Server install on a VM was stopped incorrectly this morning. When brought back up, it communicates normally on the local machine. It no longer works on TCP/IP. Attempts to communicate with the server from SSMS on a differnt machine result in
A network-related or instance-specific error occured while establishing a
connection to SQL Server. The server was not found or is not accessible.
Very that the instance name is correct and that the SQL Server is
configured to allow remote connections. (provider:Named Pipes Provider,
error:40 - Could not open a connection to SQL Server)(Microsoft SQL Server,
Error 1326)
The user name or password is incorrect
The username and password work fine when they are used locally. Have tested Windows Auth locally, sql user remotely (we don't have a domain)
In SQL Server Configuration Manager > Sql Server Network Configuration > Protocols for MSSQLServer > TCP/IP > IP Addresses everything appears correctly configured. The IPv6 IPv4 addresses are correct, and IPAll has the correct port (default 1433)
The server can ping multiple hosts on the network. They can ping it back. It's only a single non-routeable subnet. 192.168.0.*
The name of the pc matches the name of the sql server from SELECT ##SERVERNAME
The server version is 10.50.6000 which maps to SQL Server 2008 R2
First of all 1433 Port allow in Firewall (Inbound/Outbound rule)
After then try login with
ServerName: IPAddress\InstanceName,1433
Authentication : SQL Server Authentication

Connecting to Azure DB from SQL management studio is failing MSSQLSERVER_10060

I'm trying to connect to the sql server that has been created on Azure using SQL management studio, but i'm getting the following error.
Error message: An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)
I have enabled the client IP in the SQL server firewall settings.
Please let me know if anything else need to be taken cared. Thank you
To resolve this error, try one of the following actions:
Make sure that you have configured the firewall on the computer to allow this instance of SQL Server to accept connections. That is, If you are trying to connect from within a corporate network, outbound traffic over port 1433 may not be allowed by your network's firewall. If so, you cannot connect to your Azure SQL Database server unless your IT department opens port 1433. On the Azure Side, you also need to check if the NSG (associated with that subnet the Azure SQL server sitting in) allows the client IP with the specific port 1433.
Add the client IP in the SQL server firewall settings if you enable a server-level firewall.
Telnet the current IP of your Azure SQL Database server with the port to verify the network connection.
Ensure the server name you are connecting to is correct.
Check that your own firewall allows your connection across the internet to the instance.
Typically if it was the Azure firewall side, it would prompt you to add your IP to the firewall rules, provided you're connecting with an admin account.
This cause by network restriction in your lan. you can try by switching your network connnection. It worked for me.

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?

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