Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 463
Hossein Shahabi Avatar asked Nov 26 '16 16:11

Hossein Shahabi


People also ask

What ports need to be open for SQL Server?

By default, the typical ports used by SQL Server and associated database engine services are: TCP 1433, 4022, 135, 1434, UDP 1434.

How do I enable SQL port 1433 easy steps enable network access in SQL Server Configuration Manager?

To enable a server network protocol In SQL Server Configuration Manager, in the console pane, expand SQL Server Network Configuration. In the console pane, click Protocols for <instance name>. In the details pane, right-click the protocol you want to change, and then click Enable or Disable.

How can I tell if port 1433 is working for SQL Server?

On the local machine, click the Start button and enter “CMD” in the search programs and files field. If the port 1433 is closed, an error will be returned immediately. If the port 1433 is open, you will be able to connect to the MS-SQL server.


2 Answers

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:

connecting to MS SQL server with Microsoft SQL Server Management Studio if your port is forwarded

It's not : like in all other systems, you have to put ,

like image 134
Hrvoje Avatar answered Oct 17 '22 21:10

Hrvoje


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:

enter image description here

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.

like image 33
Francesco Cogno Avatar answered Oct 17 '22 23:10

Francesco Cogno