Allow SQL Server Remote Connection - sql-server

I need to connect to remote SQL Server by an ip address with a port.
But when I ping to the ip address then that reply as well. But when I try to establish the connection that failed.
I tried with Management Studio and with command prompt too.
My command was:
sqlcmd -S [IP],[port] -U [user] -P [password]
The error report as follows :
HResult 0x274C, Level 16, State 1
TCP Provider: A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection failed because
connected host has failed to respond.
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or
instance-specific error has occurred while establishing a connection to SQL Server.
Server is not found or not accessible. Check if instance name is correct and if
SQL Server is configured to allow remote connections. For more information see
SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.
I would like to know that
is there any missing steps from my client side for which I am unable to establish the connection?
or this is the matter of server configuration (Allowing remote connection)

It looks like you are actually missing the database name you would like to connect to:
EX: sqlcmd -S [IP],[port]\[DBNAME] -U [user] -P [password]

In addition to configuring the Windows Firewall to allow incoming connections on TCP Port 1433, you will need to start the SQL Server Browser service. This service can be found on the Start Menu - Microsoft SQL Server 2008 R2 - Configuration Tools - SQL Server Configuration Manager. Once there, click SQL Server Services on the left, then SQL Server Browser on the right. This is disabled by default.
Right click SQL Server Browser and choose Properties
Click the Service Tab
For property Start Mode, choose Automatic
Click Apply
Click the Log On tab
Choose the appropriate account for log on (I used built in service account)
Click Apply
Click Start
Click OK
This solved my problem on Windows Server 2008 R2 with SQL Server 2008 R2 Express Edition.

Check the firewall settings on the server that is actively hosting the database. By default, Windows Server will block all remote connections to the Database Server.

Related

SQL Server Named Instance TCPIP port settings & EndPoints/Infrastructure permissions error

I have a local installed SQL Server 2016 (Developer edition) installation on Windows 10 Pro. There is one named instance. I am a developer using MS SQL Management Studio and JetBrains DataGrip.
I just want my connections within my local machine to work with SQL Server over TCPIP using a SQL Server user account..! At the moment this only works using my Windows Authentication mapped to ServerAdmin
Named instance
RAXLENOVOT560\MSSQL2016MAIN
(authentication is mixed mode)
There are 3 issues that maybe linked:
TCP Port number does not appear to take effect within the Sql Server Configuration Manager.
The Sql Server Configuration Manager only shows limited properties on the Client Protocols/TCPIP settings. (please see screen shots)
Sql Server login user account does not connect via TCP due to an error. Login within local machine, local development from DataGrip to SQL Server.
1. TCP Port number
I have set this to 65321. However when I try and connect using this port no connection is made.
When I checked using the following SQL query I see the port number is actually 65514
SELECT DISTINCT
local_tcp_port
FROM sys.dm_exec_connections
WHERE local_tcp_port IS NOT NULL
results
local_tcp_port
--------------
65514
I change the port number in the config tool, restart ALL SQL Server services, reboot and still nothing works. Still listening on port 65514
Note I did not choose 65514, this seems to be a default from SQL Server.
2. The Sql Server Configuration Manager Properties Missing
Note the properties screen is limited only to a few options, there are usually lots more why is is? Perhaps due to running on Windows 10 Pro vs Windows Server?
3. Connection Login failure
Login from the local machine only.
I have opened the firewall for all the relevant SQL Server ports
TCP 1433
TCP 65514 (the forced sql server port)
TCP 65123 (what I would like to use)
UDP 1434 Sql Server Browser
I attempted login via a number of means
Sql Server Management Studio
Udl File
Java connection via DataGrip
Since opening the firewall, all the connections work but only if the hostname is 127.0.0.1, why can't I use the computer name? The connections also work if I use my Windows Login but NOT a SQL Server login
The login fails due to the error shown below from the SQL Server Log (which proves the TCPIP connection is reaching SQL Server).
Login-based server access validation failed with an infrastructure error. Login lacks connect endpoint permission
Date 24/04/2018 11:25:05
Log SQL Server (Current - 24/04/2018 11:20:00)
Source Logon
Message
Login failed for user 'SvrDeveloper'. Reason: Login-based server access validation failed with an infrastructure error. Login lacks connect endpoint permission. [CLIENT: 127.0.0.1]
The Sql Server User has the following permissions and settings (please see screenshot)
Name = SvrDeveloper
Server Roles = public
Securables = RAXLENOVOT560\MSSQL2016MAIN Type=Server
Securables = TSQL Default TCP Type=EndPoint
Connections
Udl Connection
[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=True;User ID="SvrAdmin";Password="Password123";Initial Catalog="";Data Source=TCP:127.0.01\MSSQL2016MAIN,65514;Network Library=DBMSSOCN;Initial File Name="";Server SPN=""
Java connection:
jdbc:sqlserver://127.0.0.1:65514;databaseName=CcTools;user=SvrDeveloper; password=Password123
Some additional information:
Version

Not able to login to sql server

I am not able to login to sql server 2012
error
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: C
ould not open a connection to SQL Server [67]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or in
stance-specific error has occurred while establishing a connection to SQL Server
. Server is not found or not accessible. Check if instance name is correct and i
f SQL Server is configured to allow remote connections. For more information see
SQL Server Books Online..
Command I am using to login "sqlcmd -S MSSQLSERVER -E"
I also tried enabling TCP/IP under sql server configuration manager.
Thanks
If you are are running the SQLCMD from the machine where the SQL Server is installed, you need to use the below command.
SQLCMD -E
If the SQL Server is on another machine, you need to use the below command. The <ServerName> is the machine name, but not the instance name.
SQLCMD -E -S <ServerName>
You need to check if SQL Server is running or not. Press Win + R and enter services.msc and press enter. (You need to do it on the machine where SQL Server is installed)
This will open the Services window. Scroll through and find SQL Server (MSSQLSERVER) and select it.
On the left side of it, you should be able to see the status. Check if the process is already running or now. If not, you need to start it before using the SQL Server.
If the SQL Server is up and running, you need to check if SQL Server is accessible from your machine. You can check it by executing below command from cmd prompt.
TELNET <ServerName> 1433
If this command does not give you any error, and opens a blank window, that means you are able to reach SQL Server machine. This will rule out any firewall issues. All you need to check is if the SQL Server instance is running or not.

Error connecting with SQL server

Hello I'm trying to connect to SQL server with Microsoft SQL server management studio. However when I try to connect I get the following error:
Cannot connect to DESKTOP-QELGJNT.
===================================
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) (.Net SqlClient Data Provider)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476
Error Number: 2
Severity: 20
State: 0
Usually you have to set up a server first before you can connect. How can I do this with SQL server management studio, if this is the reason I get this error.
I also checked under services but I couldn't click start on SQL server vss writer. That is the only sql file running I found.
I checked on YouTube and stackoverflow on a similar subject, however it didn't provide the solution for me. Could anyone help me?
This question can be helpful to others as well who have similar problems with SQL server management studio.
Is your SQL Server installed on your local computer? If yes.
Check your SQL Server Configuration Manager. If SQL Server service is in Running state.
It may possible your SQL Server service for that instance is stopped. There can be may reason one is due to service conflict with other. What you can do is
go to SQL Server Configuration Manager (type on start menu it will appear)
On left pan go to SQL Server Services
SQL Server() is running if not right click and start
If this will not resolve the issue then do check TCP/IP is enabled or not?
To enabled that
Open SQL Server Configuration Manager.
In the left pane, expand SQL Server Network Configuration, and then
click Protocols for MSSQLSERVER.
In the right pane, right-click TCP/IP, and then select Enable.
Double-click TCP/IP. The TCP/IP Properties dialog box is displayed.
On the IP Addresses tab, identify the block corresponding to the IP
address that you want to enable.
In the Enabled field, select Yes.
In the TCP Port field, enter 1433.
Click OK.

Unable to connect to SQL Server on VPS remotely

I have a VPS, installed SQL Server and everything but the problem is that I can't access the database from outside my VPS.
I tried the following:
Enable port 1433 in firewall
Enable windows and server authentication in SQL Server
Enable TCP/IP
Make sure that SQL Browser is Running
When I connect using SQL Server authentication inside my VPS, it works fine, but from my PC I get this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)
Now what should I do?
Most probably, your MS SQL server is not configured for Remote Access. Try following:
1) Open SQL Server Configuration Manager.
2) Click on Protocols for SQLEXPRESS from left hand side pane, from right hand side pane, double click on TCP/IP.This will open TCP/IP properties.
3) Under TCP/IP properties page, enter public IP address of SQL server under IP address field. Enter port number 1433 under port TCP port field.
4) Click on Apply and OK.
5) Restart the MS SQL Service.
6) Connect to MS SQL Server through SQL Server Management Studio as follows:
My response might be old though. Say you are still experiencing the same issue,
Ensure that Protocol is set to Yes
Then restart SQL Server and you
should be fine.

Error while connecting to external SQL Server with an IP using SQL Management Studio 2005

Error while connecting to external SQL Server IP using SQL Management Studio 2005 address
TITLE: Connect to Server
Cannot connect to 1.2.3.4\SQLEXPRESS.
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: SQL Network
Interfaces, error: 26 - Error Locating
Server/Instance Specified) (Microsoft
SQL Server, Error: -1)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
By default, SQL Server 2005 doesn’t allow remote connection so you have to enable it manually. So if #abatishchev's solution doesn't get you going; it may be you haven't set the permissions to connect.
Run the Surface Area Configuration Manager (it should be in the SQL Server folder in My Programs under Configuration Tools).
Choose Surface Area Configuration for Services and Connections
Select your server expand database engine and then remote connections and enable TCP/IP and / or tcp/ip and named pipes. Click Apply.
Whilst you are here check the SQL Server Browser is set to run. Expand it out and choose the service; change the startup type to be Automatic.
Try again in management studio express to connect to the machine.
Make sure that remote server allows connection to port 1433/tcp, e.g.:
using telnet client (in Windows 7 isn't installed by default, to install use Turn Windows features):
telnet 1.2.3.4 1433
or using nmap (port scanner)
nmap -sT -r -n -vv -p1433 1.2.3.4
If doesn't allow - check inbound firewall rules.

Resources