Connection to SQL Server on non standard port using SSMS - sql-server

I have a SQL Server in RDS in private subnet on port 1433.
I open a SSH tunnel and use local port 21433.
I am not able to connect it using SSMS if I give db host as localhost,21433 or .21433
Please advise what the connection string needs to be in this case, even sqlcmd did not work.
I am able to connect same DB using another clinet "Dbever"

Follow this steps :
Open the SQL Server Configuration Manager and expand the node SQL Server Network Configuration. Then Select Protocols for SQLEXPRESS (or whatever the name of your SQL Server instance is). Make sure that TCP/IP protocol is enabled.
Right click on TCP/IP and choose Properties. In the TCP/IP Properties dialog box, click on the IP Addresses tab and scroll down to IPAII section. Make sure TCP Dynamic Ports is blank and that TCP Port is set to 1433 (or whatever you want to set TCP Port).
3.First Click on Apply button and then the OK button to save your changes. After that restart your SQL Server instance.
Now you are able to connect to your SQL Server instance remotely using SQL Server Management Studio.
If there is problem persist in remote connection, you most likely need to configure your firewall settings. Make sure the TCP port 21433 is not blocked by your firewall.

Related

What port does Microsoft SQL Server Management Studio use for database connections?

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.

After changing the TCP ports of named SQL Server instance while logging through SSMS to localhost or . I still login to the old default SQL Server

I have installed named instance of the SQL Server, later I wanted to use it as default instance. So I did this:
Open SQL Server Configuration Manager
Click SQL Server Network Configuration
Click Protocols for INSTANCENAME you want to make available (i.e. SQLExpress)
Right-click TCP/IP and click Enabled
Right-click TCP/IP and go to Properties
Go to the IP Addresses tab
Scroll down to the IPAll section
Clear the field TCP Dynamic Ports (i.e. empty/blank)
Set TCP Port to 1433
Click Ok
Go to SQL Server Services
Right-click your SQL Server (INSTANCENAME) and click Restart
This made my the named instance listen on the default port. Then I did the same for the default server and I changed TCP port to the 1434 so they don't interfere.
I restarted the computer but still when I login through SQL Server Management Studio and give localhost as the server name I still access the old default server.
Why is it so, how to fix it?
when I login through SQL Server Management Studio and give localhost as the server name I still access the old default server
Probably because you are connecting over Shared Memory, not TCP/IP.
EG connect and run
select net_transport
from sys.dm_exec_connections
where session_id = ##spid
If you specify tcp:localhost you should connect to the target instance.
Note in this configuration you'll want to disable the other network protocols to avoid this confusion.

SQL Server 2014 Express Client Not Connecting

This is a new SQL Server 2014 Express installation.
The application using the SQL Server, installed on the server works, no problem connecting.
But when a client PC (on the LAN) tries to use the application, the "canned" SQL Server message says that "server does not exist or connection denied".
I think that the SQL Server is not listening on port 1433 but can't figure out why not. Here is what I tried:
Server Connection property has the box "Allow remove connections to this computer is checked"
SQL Server Browser is running.
SQL Server Configuration Manager -> Client Protocols -> TCP/IP: Port 1433 is enabled. (this one looks different from the SQL Server 2008 though where in SQL Server 2008 there were ports, IP1, IP2, and so one where port 1433 was set Active)
SQL Server Management Studio set to use Window and SQL Server Authentication.
When I run NETSTAT -a on the server, I DO NOT see the line (which I think it should) like this:
TCP ###.##.##.###:1433 ESTABLISHED.
So I am concerned that the 5 above is not showing what I am looking for. What else can I try?
Make sure the Option for remote Connections is enabled.
Right-Click on your Server, choose Properties, Connections an dcheck the box allow remote connctions.
Equally important!
Make sure your Firewall allows the traffic through the Chosen Port. Also, make sure you have the rules defined in Windows Firewall or turn off Windows Firewall altogether.
In the SQL Server Configuration Manager, when right mouse clicking on TCP/IP (in Protocols for MSSQLSERVER) there are two tabs. The second tab, at the button of the list there is IPALL which was empty. Once I entered 1433 there, the SQL Server started listening on this port. Problem Solved.

Cannot connect to remote SQL Database with SQL Server Management Console (Error 53)

I have opened up port 1433 on my firewall, but every time I try and connect to my remote SQL Database with SQL Server Management Console I receive (Microsoft SQL Server, Error: 53)
https://social.technet.microsoft.com/wiki/contents/articles/2102.how-to-troubleshoot-connecting-to-the-sql-server-database-engine.aspx
http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
Enable remote connections for SQL Server Express 2012
Short Answer
Check Firewall
Check Service is Running
Check TCP/IP is Enabled
Check SQL Server Properties "Allow Remote Connections"
Check if the SQL Server is on a restricted subnet
Then Run these if Those Do not Resolve
Right-click on TCP/IP and select Properties.
Verify that, under IP2, the IP Address is set to the computer's IP address on the local subnet.
Scroll down to IPAll.
Make sure that TCP Dynamic Ports is blank.
Make sure that TCP Port is set to 1433.
If you have a named instance then you must have the SQL Server Browser Service enabled
The browser service runs on port UDP 1434 and this must be allowed through your firewall
Hail Mary Pass if this is Still not Resolved
Go to the client machine, and run cliconfg.exe If named pipes is listed first, demote it, and promote TCP/IP.
check if the firewall is blocking the named pipes port, which usually is 445
What you need to do is go into SQL Server Configuration Manager where SQL Server is installed.
In the Start Menu, under the Microsoft SQL Server folder, open the Configuration Tools folder and select SQL Server Configuration Manager.
In the Config Manager, click the arrow next to SQL Server Network Configuration, then click on "Protocols for {Instance}". {Instance} will be your install, if it's the default instance it will be MSSQLSERVER.
On the right side, make sure that TCP/IP is "Enabled". Double click TCP/IP, in the window that opens, change the drop down to "Yes".
Here is the how to fix it and gain your connectivity back:
Click WindowsKey + R and enter services.msc
Once Services opens scroll down and locate service SQL Server
Highlight the service and click START
Wait for the service to start and retry to connect to your MSSQL instance
It should now work again and you will be able to connect to your MSSQL instance and run queries.
I have solved this problem. Please refer to this thread: http://social.technet.microsoft.com/Forums/forefront/en-US/d2624655-e6ff-4947-b1a8-a2edcffd8a21/denied-connection-netbios-session-protocol#68321990-4ac4-46fa-b7f8-9e0ded3234bb
In detail: I was receiving the following error from ISA when trying to connect from my SBS 2003 Server to my offsite MSSQL Database Provider via SQL Server Management Studio:
Denied Connection
Log type: Firewall service
Status: A packet generated on the local host was rejected because its source IP address is assigned to one network adapter and its destination IP address is reachable through another network adapter.
Rule:
Source: Local Host ( 192.168.1.1:29859)
Destination: External (...:139)
Protocol: NetBios Session
I have figured this out. I had to add "Local Host" as one of the sources for the ISA Rule that I had initially created to allow SQL Server Management Console connections in the first place. That rule was allowing "Internal" sources but not the Local Host (127.0.01), which is needed for this scenario.
in SSMS while opening give the server name as your_Hostname\your_sqlservername (give both the names as applicable instead of local or just only servername) it works fine.
I could ping my Virtual Machine SQL server but couldn't connect to it.
I disabled my wired and wireless NICs and then it connected !

Firewall Port 1433 not opening

I am using MS Server 2008 with MSSQL 2008-R2 as database server.
Each time for some work i have to login to server via Remote connection.I tried to configure
the SQL Server remote connection on, followed the following steps....
1.Created Inbound and outbound rules for tcp port 1433.
2.In sqlserver configuration manager ,all is set for IP address and POrt no properties.
3.Set the SqlServer instance for remote connections.
But still its not working.
Also when i checked port 1433 for tcp on local computer it is shown closed.
thanks in advance.......
Probably port 1433 is disabled, so enable it using MS WIndows firewall.
or just use
netsh firewall set portopening protocol = TCP port = 1433 name = SQLPort mode = ENABLE scope = SUBNET profile = CURRENT
Probably MS SQL Server Browser Service is not running. So go to Services and start it.
or just execute under Run menu
%windir%\system32\services.msc
Probably TCP/IP channel is disabled under SQL Server 2008/2014 Configuration Manager. SO go there and enable all TCP/IP options.
Just in case at the same place (SQL Server 2008/2014 Configuration Manager) make sure you have 1433 port.
Make sure that SQL server is configured to allow remote connections. Use MS SQL Management Studio and right click on the top node which server itself.
In the SQL Server Configuration Manager->SQL Server Network Configuration->Protocols, check that named pipes and tcp/ip are enabled.
If that doesn't work then it may be your firewall blocking it, try this link: http://msdn.microsoft.com/en-us/library/cc646023.aspx
This may be useful too:
http://support.microsoft.com/kb/287932
If named pipes and TCP/IP access are already enabled in SQL Server Configuration Manager, then you need to either add a rule for UDP port 1434, or a rule for sqlbrowser.exe so that the SSMS client can talk to the SQL Server Browser service.
I actually see people having this problem surprisingly often so I wrote up an explanation here: http://blog.dereenigne.com/microsoft-sql-server-dynamic-ports-windows-firewall-and-you/
If you're trying to connect to an SQL Server Express instance as is my case right now... it doesn't use port 1433 by default. One must check the IpAll => TCP Dynamic Ports in Sql Server Configuration Manager. Mine is 52848.
After entering the correct port 52848 in DbSchema app (the one I'm trying to use), it connected successfully.
Check the following screenshot:
This is the way to go:
The default SQL Server express installation does not enable TCP
network protocols, so here are some steps to take to be able to
communicate with SQL Server Express. These steps should be similar for
MS SQL Server Express 2017, 2016, 2014, 2012, 2008, and 2005.
Launch the SQL Server Configuration Manager. It should be in the Start -> Programs -> Microsoft SQL Server 2005 -> Configuration Tools start menu option.
Select the SQL Server 2005 Network Configuration tab. There should be a Protocols for SQLExpress option, and one of the protocols should be TCP IP.
Enable the TCP IP protocol if it is not enabled.
The default port for SQL Express may not be 1433. To find the port it is listening on, right-click on the TCP IP protocol and scroll all the way down to the IP All heading. There should be a section called TCP Dynamic Ports. This should list the port SQL Express is listening on. You can then put this value into the port field when adding the connection profile via RazorSQL.
Make sure to restart SQL Express before trying to connect.
Text kindly reproduced from:
https://razorsql.com/docs/support_sqlserver_express.html
I had multiple NICs in my server. When I went to SQL Server Network Configuration -> TCP/IP and right clicked for properties there was a list of the NICs and at the bottom was the open port for my SQLEXPRESS. It was not 1433..... I do not know if there is a default but mine was in the 49,000 s.

Resources