I recently set up SQL Server locally and have followed the numerous guidelines on this website and others to connect to it from a different network:
Connect to MS SQL Server 2014 from a computer on a different network
Connect to MS SQL Server 2014 from a computer on a different network
Firewall rules to allow remote connection to SQL Server in a different domain
How to use SQL server from a different network
This is what I have tried so far:
Ports 1433 and 1434 have been enabled in SQL Server Config Manager
Based on these suggestions in the links above, I have added inbound rules to my firewall to create exceptions for SQL Server and its associated ports (Ports: 1433 & 1434).
When I try using telnet to connect, I get the following:
Connection closed by remote host
When I try checking the status of my port from the following website:
http://ping.eu/port-chk/
It indicates that my port is closed (both 1433 & 1434).
When I try connecting from a different machine on the same network, I am able to do so without issue.
I do not understand what other layer of protection exists that is blocking connections to my local version of SQL Server.
Any guidance is greatly appreciated.
Thanks.
Related
I am using Microsoft SQL Server Management Studio 17 to connect to a remote Microsoft SQL Server database. Looking at the connection dialog of Studio 17, I don't see any port number setting. Google tells me that Studio uses port 1433 by default.
I tried to use telnet to check if port 1433 is listening on the remote server: telnet example.company.com 1433
However, the connection failed. How can I find the port used for this database connection?
You could connect SSMS to your DB, run ProcessExplorer and examine the properties of ssms.exe. On the "TCP/IP" tab you possibly find what you are asking for:
Make sure you have connectivity to the server first. Since you mentioned "remote" there could be a firewall in the way, so your solution is going to depend on your network topology.
Can you ping the server? If ping works, I would reach out to the owner of the server and verify the DB connection parameters. Maybe your IP needs to be whitelisted. Etc. Etc.
Check if the server host has inbound port 1433 enabled, and whether TCP/IP is enabled using the SQL server configuration manager. If the SQL server instance in question sits on the cloud, you might want to check the specific provider's firewall rules on the container and adjust to permit 1433 inbound connections. The port setting entirely lies on where the actual SQL server instance sits. The management studio in your remote client will not be using any port.
I'll preface my question with: I am an absolute beginner with respects to the nature of MS SQL Server and have a layman's understanding of networking and 'computers' in general...
So, I'm trying to replicate an environment where:
There is an 'application server' which hosts HPE's ALM
This communicates with a database server with a Microsoft SQL Server DB
I currently have Microsoft SQL 2012 Server with a sample DB uploaded onto it on one laptop (Laptop 1) and the ALM software on the other laptop (Laptop 2). Both are connected to the same WiFi network.
Laptop 2 is asking me for Database parameters such as:
DB Host Name
DB Port Number (1433 by default)
OR Connection String
I have little idea of what I'm doing - I'd have thought it might be possible to connect to the DB through some sort of variant of the IP address of Laptop 1... but I'm unsure.
How can I connect to a MS SQL 2012 DB from one laptop to another? I realise this is probably a loaded question - I'd be happy if someone can point me in the right direction rather than an exact answer!
Thanks guys,
ST
I see two potential issues:
A corporate laptop might have firewall restrictions. So, you have to
open port 1433 for SQL Server.
Possibly you are playing with SQL Express, which by default, does not
have TCP/IP connection enabled. To enable it run "SQL Server
configuration manager", go to Network
configuration->Protocols->TCP/IP->Enable->restart SQL Server. Also check other properties. If static port 1433 is not set - set it.
Two types of adjustments must be set before connecting to the remote SQL Server. These settings are necessary because without them the connection to the remote SQL Server will not be able to be successfully created
Configuration settings:
-The SQL Server instance to allow the protocol being requested
-Allow access through the Window Firewall
1- Enabling TCP/IP protocol
2- Configuring Windows Firewall
For More details see the link :
https://www.sqlshack.com/how-to-connect-to-a-remote-sql-server/
I'm not able to connect to my SQL Server 2017 that is installed on my desktop from any remote computers.
Here are the steps and actions I have taken:
I followed all troubleshooting steps on https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/troubleshoot-connecting-to-the-sql-server-database-engine#testing-a-local-connection
Turned off windows firewall on both computers (to eliminate this)
Tested tcp by connecting on the same computer as the server with tcp:localhost and I was able to connect
Used a port check tool to make sure the port was open
SQL Server remote connections allowed: http://prntscr.com/gvb1gb
SQL Server tcp/udp turned on: http://prntscr.com/gvb2yh
Router settings showing port forwarding is configured: http://prntscr.com/gvb3jm
I ran out of ideas and I don't know what else to do to connect to this sql server from a remote computer. Does anyone have any ideas on what I can try next?
UPDATE: I added port forwarding for 1434 udp in addition to the 1433: http://prntscr.com/gvbd01
Yesterday I had no problems. Now when any client (even MSSMS from a client machine) tries to access sql server located on a server in the domain I get the following error: TITLE: Connect to Server
Cannot connect to SERVER\Instance
A network-related or instance-specific error occurred while establishing a connection to SQL Server. ...
SQL server is 2014 on a Windows 2012 R2 Server which also hosts the Active Directory.
I can connect using MSSMS from the server itself to the database. The log states that the service started and is listening on port 63782. I can also connect to sql server from the host machine using ip:port (192.168.0.2, 63782). But I cannot connect to it this way from the clients. (I made no changes to the firewall and the rule for lan-lan is allow all services and all connections).
Shared Memory, TCP/IP and Named Pipes are enabled on the sql server configuration Manager.
I can ping to the server from the clients and to the clients from the server.
The main difference between yesterday and today is that I had to reinstall the DNS on the server. The DNS appears to be working very well and I can't find any DNS errors on the server. I don't think its the firewall but I added two rules that allow UDP and TCP specifically within the local network (even though there is a policy which allows all traffic within the local network).
I am at a loss and would appreciate some assistance into solving the problem or even where to look.
Initial Attempt
I have an Azure VM with Windows Server 2012, on which I just installed SQL Server 2012 Express Database Engine component. Then, I followed the instructions here to connect remotely with SQL Server Management Studio.
Create a TCP endpoint for the virtual machine
Open TCP ports in the Windows firewall
Configure SQL Server to listen on the TCP protocol
Configure SQL Server for mixed mode authentication
Create SQL Server authentication logins
Determine the DNS name of the virtual machine
Connect to the Database Engine from another computer
After step seven I received the following 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: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(Microsoft SQL Server, Error: 53)
What else do I need to configure before connecting remotely?
Troubleshooting
I have been following the troubleshooting instructions here. Each blockquote below is a step described that that link.
Confirm the instance of the SQL Server Database Engine is installed
and running.
Done. We installed SQL Server Express, and it is running as a named instance called SQLEXPRESS.
If you are attempting to connect to a named instance, make sure the
SQL Server Browser service is running.
Done. We followed the steps here to turn on the SQL Server Browser service.
Get the IP Address of the computer.
Done. We will use these later for testing connectivity and maybe for setting up a static port for SQLEXPRESS.
10.241.62.155
fe80::45c:8c29:e19f:f78b%15
Get the TCP port number used by SQL Server.
Done. The SQL Server Management Studio server logs showed that the server was listening on port 49169.
Enable Protocols
Done. We had already enabled TCP/IP in the configuration manager, but we restarted the SQL Server Service just in case.
Testing TCP/IP Connectivity
Done. We used tcping.exe to test connectivity (cmd ping doesn't work quickly with Azure.) We were able to connect to port 80.
tcping.exe buddha.cloudapp.net > successful
tcping.exe buddha.cloudapp.net 80 > successful
Testing a Local Connection
Done. We used sqlcmd.exe from the command prompt and were able to connect locally via TCP with a username and password.
sqlcmd -S Buddha\SQLEXPRESS (success via shared memory protocol)
sqlcmd -S tcp:Buddha\SQLEXPRESS (success via TCP)
sqlcmd -S tcp:Buddha\SQLEXPRESS -U sa -P (success via TCP with username)
sqlcmd -S tcp:10.241.62.155\SQLEXPRESS -U sa -P (success with internal IP)
Opening a Port in the Firewall
We opened the port on which we SQLEXPRESS listens. The server logs (above) showed that SQLEXPRESS was listening on port 49169, but this is just one of many dynamic ports, and we wanted to set up the static port 1435.
Use WF.msc to create an inbound TCP rule for port 1435.
Use Azure Management Portal to create a TCP endpoint for port 1435.
The troubleshooting instructions also say:
If you are connecting to a named instance or a port other than TCP
port 1433, you must also open the UDP port 1434 for the SQL Server
Browser service.
Since we are connecting SQLEXPRESS (a named instance), we needed to open port 1434 for UDP.
Use WF.msc to create an inbound UCP rule for port 1434.
Use Azure Management Portal to create a UDP endpoint for port 1434
Further research about connecting to named instances revealed dynamic port issues. The reason why we are using port 1435 (static) instead of port 49169 (one of many effective options.)
Instances of SQL Server Express, SQL Server Compact, and named
instances of the Database Engine use dynamic ports. To configure these
instances to use a specific port, see Configure a Server to Listen on
a Specific TCP Port (SQL Server Configuration Manager). and
here.
Done. We went to SQL Configuration Manager > SQL Server Network Configuration > Protocols for SQLEXPRESS > TCP/IP, we did the following.
Protocol Tab > Listen All > NO.
IP Addresses Tab > for each listed address
Enabled > Yes
TCP Dynamic Ports > Blank (delete the zero)
TCP Port > 1435 (or your choice)
After restarting the SQLEXPRESS service, we again looked in the SQL Server Management Studio logs, and found that the Server is Listening on port 1435!!! Hooray!
Testing the Connection
Done. We opened SQL Server Management Studio on our local (non-Azure) computer and connected.
buddha.cloudapp.net,1435 OR buddha.cloudapp.net\SQLEXPRESS
sa
password
Success.
Here are the three web pages on which we found the answer. The most difficult part was setting up static ports for SQLEXPRESS.
Provisioning a SQL Server Virtual Machine on Windows Azure. These initial instructions provided 25% of the answer.
How to Troubleshoot Connecting to the SQL Server Database Engine. Reading this carefully provided another 50% of the answer.
How to configure SQL server to listen on different ports on different IP addresses?. This enabled setting up static ports for named instances (eg SQLEXPRESS.) It took us the final 25% of the way to the answer.
The fact that you're getting an error from the Names Pipes Provider tells us that you're not using the TCP/IP protocol when you're trying to establish the connection. Try adding the "tcp" prefix and specifying the port number:
tcp:name.cloudapp.net,1433
I too struggled with something similar. My guess is your actual problem is connecting to a SQL Express instance running on a different machine. The steps to do this can be summarized as follows:
Ensure SQL Express is configured for SQL Authentication as well as Windows Authentication (the default). You do this via SQL Server Management Studio (SSMS) Server Properties/Security
In SSMS create a new login called "sqlUser", say, with a suitable password, "sql", say. Ensure this new login is set for SQL Authentication, not Windows Authentication. SSMS Server Security/Logins/Properties/General. Also ensure "Enforce password policy" is unchecked
Under Properties/Server Roles ensure this new user has the "sysadmin" role
In SQL Server Configuration Manager SSCM (search for SQLServerManagerxx.msc file in Windows\SysWOW64 if you can't find SSCM) under SQL Server Network Configuration/Protocols for SQLExpress make sure TCP/IP is enabled. You can disable Named Pipes if you want
Right-click protocol TCP/IP and on the IPAddresses tab, ensure every one of the IP addresses is set to Enabled Yes, and TCP Port 1433 (this is the default port for SQL Server)
In Windows Firewall (WF.msc) create two new Inbound Rules - one for SQL Server and another for SQL Browser Service. For SQL Server you need to open TCP Port 1433 (if you are using the default port for SQL Server) and very importantly for the SQL Browser Service you need to open UDP Port 1434. Name these two rules suitably in your firewall
Stop and restart the SQL Server Service using either SSCM or the Services.msc snap-in
In the Services.msc snap-in make sure SQL Browser Service Startup Type is Automatic and then start this service
At this point you should be able to connect remotely, using SQL Authentication, user "sqlUser" password "sql" to the SQL Express instance configured as above. A final tip and easy way to check this out is to create an empty text file with the .UDL extension, say "Test.UDL" on your desktop. Double-clicking to edit this file invokes the Microsoft Data Link Properties dialog with which you can quickly test your remote SQL connection