Unable to connect to SQL Server 2014 remotely - sql-server

Unable to connect to SQL Server remotely
I have installed SQL Server 2014 Express on Windows 10. I can connect to server locally by entering: computername\SQLEXPRESS or 192.168.0.xxx\SQLEXPRESS
When I try to connect to the server using public ipadress
122.xxx.xxx.xxx\SQLSERVER
I get an error:
Error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient
Data Provider)
I also have host name from dlinkddns, tried connecting with host name with same error.
Steps which I have tried:
Enabled remote connections.
Configured 1433 TCP port to be allowed in firewall. Disabled antivirus program. I tried disabling firewall with no success.
Enabled all protocols "TCP/IP', 'Named Pipes', 'Shared memory'
Under TCP/IP properties, changed 'IP All' 'TCP Port' to 1433. I tried enabling IP1 to public ipadress with port 1433 with no success.
I have dlink DIR 816 router, i dont see anything called port forwarding instead it has 'port triggering', i configured to allow port 1433 TCP and 1434 UDP.
I can ping both ipadress and hostname with success but the server would not connect.
I have tried everything to the best of my knowledge but nothing works, any inputs to setup my connection remotely will be of great help!

The error is pretty specific here.
error: 26 - Error Locating Server/Instance Specified (.Net SqlClient Data Provider)
You must understand one thing. Your local IP (192.168.0.xxx) is not visible from WWW. Only your Public IP or Global IP is. Once someone comes inside your network they will be able to ping your IP (192.168.0.xxx).
To make it work, you must have the SQL Server installed in a computer whose local IP is accessible from the internet. That means, it should be hosted in a Domain.
Connecting to SQL Server over the Internet

We can connect to SQL Server remotely over the internet if the Server has a static public IP address and port forwarding is configured on the router to allow remote connection requests through the router firewall.
In the router firewall settings, there is normally a games and application section, in there add SQL application and give the port range (1433 normally) and then direct the incoming connection by selecting the SQL Server device name on the network.

I fixed the issue by adding local ip into DMZ on my router. Everything works like a charm now.

Related

Connection to 1433 port not working from outside, while port is redirected from router

I am trying to open access to my SQL Server from outside my network, but while my ports are open in my Windows Firewall and routed from my router, telnet can't connect.
To explain a bit more I have opened both TCP 1433 and UDP 1434 ports in my Windows Firewall to allow remote access to my SQL Server.
Ports seems to be properly opened in my windows firewall as both a telnet [local_server_ip] 1433 and SSMS can connect from a different computer within my local network.
When trying to connect from outside my network (using my external IP) Telnet can't connect (Connect failed).
In my router, ports are redirected (TCP 1433 and UDP 1434) and I also tried setting my SQL Server IP as DMZ but it did not went through. My other port redirection works properly so I don't think it comes from the router (for instance I have Emby as a media server, and I can access it from outside my network or use telnet to connect to the port opened for this service).
Am I missing a configuration in SQL Server configuration manager? For instance I had to manually set the TCP port in SQL Server Network Configuration > TCP/IP properties > IP Adresses > IPAll and set TCP Port as 1433
Or can it come from either my Windows Firewall (even though the inbound rules has similar characteristics as the inbound rule for my Emby server) or my router?
So locally it all seems to work, but from outside it does not? This does indicate your router NAT setting being an issue.
Just to point out, exposing an SQL Server to public internet is relatively insecure. Ideally you add a VPN to your local network and use that to reach the SQL server instead. Just to point out, I can imagine it could work, but you might want to rethink the setup.

SQL Server TCP/IP times out

I have to connect to a fresh SQL Server Express 2017 on a machine not part of my domain. I have configured
Mixed Mode Installation with sa with password
SSMS -> Server -> Properties -> Connections -> Allow remote connections
SQL Configuration Manager -> Instance "EXPRESS2017" -> TCP/IP: Enable and Active and Port 1438
Restarted the "SQL Server (EXPRESS2017)" service.
I now tried to access from a remote computer, and got a timeout. I then tried to connect from the local SSMS, which works without special settings, but when under options, forced "Protocol: TCP/IP" is set, with the same credentials as before, I also got a timeout.
So am I right that I can rule out the firewall or problems finding the instance, and everything points towards a configuration issue in TCP/IP protocol, or did I overlook some setting?
EDIT: I have disabled Windows firewall, and no other firewall is installed on the computer. I have restarted the computer. I also found this article about PortQry and had a check - locally:
C:\Users\Administrator\Downloads>PortQry.exe -n 172.17.41.124 -p UDP -e 1434
Querying target system called:
172.17.41.124
Attempting to resolve IP address to a name...
IP address resolved to WIN-AECL8CJVS7E.test.local
querying...
UDP port 1434 (ms-sql-m service): NOT LISTENING
EDIT: I have run NETSTAT and it seems no port in the 14xx range is open at all, although the SQL Server Browser service is running. I must be missing something there...
You did not show your connection string, but I suppose you use your instance name here.
In order to connect to SQL Server the network library has to know 2 things: IP address and a port. Your instance is named and uses non-default port 1438.
So your connection string should use 172.17.41.124,1438 as server name, or, alternatively, you can use instance name like this: 172.17.41.124\EXPRESS2017 but SQL Server Browser should run.

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 port forwarding

I forwarded port 1433 to 9082 on my server, at firewall set to allow for inbound and outbound, at SQL Server Allow Remote is ON.
But, I can't connect to my SQL Server from client.
I installed SQL Server 2012.
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: 25 - Connection string is not valid)
Solution to problems connecting to MS SQL server with Microsoft SQL Server Management Studio if your port is forwarded
I had problem with this as well. It's been bugging me for days now. Finally I stumbled on solution on this page so I'll exclude it as screenshot:
It's not : like in all other systems, you have to put ,
First off check in the ERRORLOG the port used by SQL Server (there is no guarantee it will always listen on 1433, or if TCP is enabled at all).
In the ERRORLOG, at startup, you will find a line like this one:
In my case the port is indeed 1433 but yours may be different. If needed, you can change it using the SQL Server Configuration Manager.
Secondly, if you are forwarding a port to a different one (like your example from 1433 to 9082) you are in fact disabling the SQL Server Browser. This happens because SQL Server Browser does not know of your port forward so it will tell the clients to connect to 1433 (supposing you are allowing UDP 1434 otherwise you won't be able to reach SQL Server Browser at all).
You can connect to a SQL Instance without using the SQL Server Browser though, all you need is to specify the port in the connection string (without the instance name, if any).
For example, if your instance is called MYSERVER/INST your connection string will be something like:
User ID=*****;Password=*****;server=tcp:MYSERVER,9082
Also make sure to configure your SPNs manually otherwise Kerberos won't work.
You can find more details on how to compose the right connection string here: SqlConnection.ConnectionString Property.
try config your router first. after all connect. Btw, already enable TCP/IP #sql yet or not?make sure open port for sql.
check on sql configuration enable or not for open connection
check firewall open or not
check router open or not
check connection lag or not(if network). local no need
make sure sql browser and agent run(for xp if not xp just enable sql browser)
if not all there maybe you wrong installation. if for network work install local/system. not network(this for attach #server cluster)

Cannot Access Name Instance over VPN

I am having an issue connecting to a SQL server instance with management studio over VPN. I can connect to the default instance (i.e. SERVERNAME) over the VPN connection but I cannot connect to another instance on the same server (i.e SERVERNAME\INSTANCE) over the same VPN connection. All of the settings are the same in SQL Configuration manager.
Additionally, I can connect to the named instance just fine from any box "inside" the network. The error I am receiving is a general, "A network-related or instance-specific error occurred... Error 26."
Thanks
EDIT: I should also point out that I can use IPADDRESS to connect, but IPADDRESS\INSTANCE does not work.
To (partially) resolve the situation you need to choose from one of these workarounds when connecting over VPN:
Enable and use SQL Server Authentication instead of Windows Authentication and a static port for the SQL Server instance (always specifying the port value in the connection string);
Use a static port for the SQL Server instance (always specifying the port value in the connection string), enable that TCP port in your server firewalls, and specify the public server name or its external IP address (provided that it is exposed outside the local network);
Enable trust between your source and destination domains (not applicable for connections “on the fly”).
Personally I decided to use the first workaround as it was the easier to implement and the most secure however If the problem persists, verify the server doesn't have an IPSEC policy that restricts access to the SQL Server port via IP address. That also could result in you being blocked.

Resources