You are on page 1of 15

16/4/2018 How to connect to a remote SQL Server

SQLShack Español 

How to connect to a remote SQL Server

February 18, 2016 by Marko Zivkovic

In this article, we will explain step by step how to connect remotely to a SQL Server Express instance.
Remote access is the ability to get access to a SQL Server from a remote distance in order to
manipulate data which are located on that SQL Server.

There are two types of adjustments which must be set before connecting to the remote SQL Server.
These settings are important because without them the connection to the remote SQL Server will not
be able to be successfully created

Configuration settings:

1. The SQL Server instance to allow the protocol being requested

2. Allow access through the Window Firewall

In order to allow access to SQL Server instance, we have to enable TCP/IP protocol which is not
enabled by default. TCP/IP (Transmission Control Protocol/Internet Protocol) is a set of protocols
developed to allow networked computers to share resources over the network. It was developed by
DARPA under the ARPANET in the early 1970s.

In order to establish a successful remote connection is to set up appropriate ports through the
Window Firewall. In SQL Server there are two types of instances. First is a default instance and the
second is a named instance. To connect to the default instance of Database Engine, or named instance
that is the only instance installed on the machine, the TCP port 1433 is the only port that you need to

But if you have multiple name instances installed on your machine, to connect with one of them, we
must provide a port number which corresponding to appropriate instance name. By default named
instance used dynamic port, which means that every time when the Database Engine starts new port
number is assigned. Because of that it is difficult to configure Windows Firewall to enable access.

In order to resolve this problem, there is a SQL Browser service, which provide the TCP port number
that corresponds to the named instances. The SQL Browser services use UDP port 1434. Now we met
with the basic matters relating to remote connection, let’s continue with the setup procedure.

E bli TCP/IP t l 1/15
16/4/2018 How to connect to a remote SQL Server
Enabling TCP/IP protocol

The first step is to enable TCP/IP protocol on the SQL Server service. Open the SQL Server
Configuration Manager in the Configuration Tools folder under the Microsoft SQL Server folder:

From the SQL Server Network Configuration node, select the Protocols item for the appropriate
SQL Server. In the details pane, right click the TCP/IP item and select the Enable option: 2/15
16/4/2018 How to connect to a remote SQL Server

After this step the Warning box pop up in which informs us that changes that are made won’t take
effect until the next time service is started.

In order for the changes take effect, from console pane, select the SQL Server Services and from the
details pane, right click the SQL Server (SQLEXPRESS) database engine instance and click the Restart

Now the service started with TCP/IP enabled, but still can’t connect remotely until we configure the
Windows Firewall.

Configuring Windows Firewall

From the Control Panel choose Windows Firewall and click the Advanced settings or just type
wf.msc in Search program and files from the Start menu: 3/15
16/4/2018 How to connect to a remote SQL Server

Inbound Rules: You can allow or block traffic attempts to access the computer that matches
certain criteria in the rule. By default inbound traffic is blocked, to allow traffic to access
computer, you need to create inbound rule.
Outbound Rules: You can allow or block traffic originating from specifying computer creating
rules. By default outbound traffic is allowed, so you need to create the rule that block outbound

In the Windows Firewall with Advanced Security, click the Inbound Rules from the left pane, right
click Inbound Rules and select the New Rule or from the Actions pane click the New Rule: 4/15
16/4/2018 How to connect to a remote SQL Server

On which you will click, it’s up to you. In both case the New Inbound Rule Wizard will appear. Under
the Rule Type choose Port and click the Next button:

From this link you can more informed of all rule types which are shown in the image above.

In the Protocols and Ports there are a several options that you can choose, depending on which type
of protocols you select.

If you are wondering what is the difference between the TCP and UDP protocols you can find from this

As we mentioned at the beginning of the article TCP is used for the default instance and named
instance if is the only instance installed on the machine and default port is 1433.

All local ports: Rule applies on all ports from the selected protocol.
Specific local ports: In the text box you specify a port or set of ports to which the rule applies.

For this example, select the UDP protocol and in the Specific local ports enter port number 1434. To
proceed with the settings SQL Browser services, click the Next button: 5/15
16/4/2018 How to connect to a remote SQL Server

Allow the connection: Includes all connections secure and insecure.

Allow the connection if it is secure: Includes only connection if it is made through a secure
Block the connection: Blocks all connections secure and insecure.

In the Action dialog choose Allow the connection and click the Next button: 6/15
16/4/2018 How to connect to a remote SQL Server

Domain: The setting is applied only when a computer is connected to a domain.

Private: The setting is applied when a computer is connected to a network that is identified as a
private network.
Public: The setting is applied when a computer is connected to untrusted public network.

In the Profile dialog choose all three profiles and click the Next:

On this step give the rule a name and click the Finish.

Note: When we give the name of the rule, please write some descriptive name that you can
understand later, when you need to find them or edit in the Inbound Rules list. 7/15
16/4/2018 How to connect to a remote SQL Server

Now create an allow rule for the database engine instance.

Go to the New Rule and from the Rule Type select the Custom rule: 8/15
16/4/2018 How to connect to a remote SQL Server

In the Program under the Services click the Customize button:

From the Customize Service Settings under Apply to this service select database engine instance
service and click the OK button: 9/15
16/4/2018 How to connect to a remote SQL Server

Then click the Next all the way to the Name dialog, give rule a name and click the Finish:

Now when all rules are set up, you are ready to connect to remote SQL Server.

Start the SQL Server, in the dialog window for the Server name enters the name of the instance that
you want to connect with. From the Authentication drop down box, select the SQL Server
Authentication and for the field Login and the Password enter your credentials then click the
Connect button. 10/15
16/4/2018 How to connect to a remote SQL Server

See more

Consider these free tools for SQL Server that improve database developer productivity.

Related posts

How to install SQL Server Management Studio 2008

Best practices after installing Microsoft SQL Server
SQL Server 2014 – Install a clustered instance – step-by-step (1/3)
How to run a local SQL Report from an Azure VM Database

Marko Zivkovic
Marko is a Mechanical engineer, who likes to play basketball, foosball (table-
soccer) and listen to rock music. He is interested in SQL code, PHP development,
HTML and CSS techniques.

Currently working for ApexSQL LLC as a Software Sales Engineer, he is helping

customers with any technical issues and does quality assurance for ApexSQL
Complete, ApexSQL Refactor and ApexSQL Search free add-ins. 11/15
16/4/2018 How to connect to a remote SQL Server

View all posts by Marko Zivkovic

Related Posts:
1. SQL Server network configuration
2. Querying remote data sources in SQL Server
3. How to migrate your database to an Azure Virtual Machine
4. Configuring the Azure SQL Database Firewall
5. Using Power BI Desktop to connect to SQL Server and Facebook



14 Comments SQL Shack 

1 Login

Sort by Best
 Recommend 12 ⤤ Share

Join the discussion…



Khaldac • 4 months ago

This is fantastic! I searched for days to find an answer to why my remote app couldn't connect
to my local DB. I followed your instructions and Eureka! It works perfectly. Thank you, thank
you, thank you!
6△ ▽ • Reply • Share ›

Marko Živković > Khaldac • 3 months ago

Hi Khaldac,

Thank you very much for your feedback. I'm glad that I could
5△ ▽ • Reply • Share ›

Jeff Stevens • 5 months ago

Cheers Marko, this has worked perfectly and saved me a lot of time.
Many thanks,
6△ ▽ • Reply • Share ›

Ž > 12/15
16/4/2018 How to connect to a remote SQL Server
Marko Živković > Jeff Stevens • 5 months ago
Hi Jeff,

Thanks for the comment and you're very welcome. I'm glad
that you liked the article and that you find it useful.

Best regards,
6△ ▽ • Reply • Share ›

Mohmd Nader • 8 months ago

Thanks ... but I'v problem .. i installed sql server on windows server 2008 r2 .. i cant find the sql
server to add it to windows firewall .
6△ ▽ • Reply • Share ›

Marko > Mohmd Nader • 8 months ago

Hi Mohmd,

Let’s try another way

Choose the Program

radio button instead of the Custom
radio button in the Rule Type tab.

Under the Program

tab choose the Browse button.

Under the Open dialog find the sqlservr.exe

For example: C:\Program Files\Microsoft SQL


see more

6△ ▽ • Reply • Share ›

Firingpin • 8 months ago

"Doesn't work. But I know everyone has their half-baked idea of how Microsoft's over-
engineered platforms are supposed to work. Excellent explanation, though. Thanks.
6△ ▽ • Reply • Share ›

Marko > Firingpin • 8 months ago

Hi Firingpin,

Yes, you are right and many thanks for the kind words
6 R l Sh 13/15
16/4/2018 How to connect to a remote SQL Server
6△ ▽ • Reply • Share ›

Muhammad • a year ago

hi, can i connect through internet like public ip? please help me
5△ ▽ • Reply • Share ›

Marko > Muhammad • a year ago

Hi Muhammad,

Yes you may, please watch this video

Here is shown how to connect SQL Server through Internet
5△ ▽ • Reply • Share ›

Muhammad > Marko • a year ago

yes, i saw this video
in the video i saw port forwarding to connect sql server over internet, i have
followed all steps but can not connect via public ip here some screen shot i have
shared with you
please help me what i can do
5△ ▽ • Reply • Share ›

Marko > Muhammad • a year ago

Hi Muhammad,

Could you please send an email to with detailed 14/15
16/4/2018 How to connect to a remote SQL Server

information and the steps that you did for connect via public ip and we
will try
to help you.

In addition, answer the following questions, please:

- Is SQL auth. enabled on Your SQL Server?

- Do You have any AV program installed on Your system (write

the program names)

- Do You have modem after router in Your LAN?

5△ ▽ • Reply • Share ›

BasharBasim • a year ago

thank you&#160
5△ ▽ • Reply • Share ›

costeakai • a year ago


thanks a lot!
5△ ▽ • Reply • Share ›


What’s new in SQL Server Management Understanding SQL Server query plan
Studio 17.4; Always On AG dashboard … cache
2 comments • 4 months ago 1 comment • 3 months ago
Ahmad Zuhair Yaseen — Many thanks Michael Prashanth Jayaram — Hello Ben,Thanks for
Avatarfor you comment here.This happens when you Avatarthe work. The content gives a good baseline to
have the option "Enable Parameterization for understand advanced concepts such as Query

Migrating SSRS content with PowerShell How to implement a graph database in SQL
2 comments • 3 months ago Server 2017
Craig — Hi Alberto, Sorry I didn't get back to 2 comments • 4 months ago
Avataryou sooner. For SSRS 2017 you can use the Esat Erkeç — Hello Wolney Marconi
REST API based PowerShell commands in the AvatarMaiaThanks for your thoughts about
article.Unfortunately I can not allow copy entire 15/15