SQL Server cannot connect to localhost:1433 - sql-server

I have checked the above post
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-server-to-listen-on-a-specific-tcp-port?view=sql-server-ver16
and I am sure my SQL Server is listening on port 1433.
But when I login through ssms, in server name, if I use
localhost:1433
an error will be thrown, but if I just use
localhost
then I can login successfully, why?

Related

SQL Server has lost tcp/ip connectivity, works locally

An SQL Server install on a VM was stopped incorrectly this morning. When brought back up, it communicates normally on the local machine. It no longer works on TCP/IP. Attempts to communicate with the server from SSMS on a differnt machine result in
A network-related or instance-specific error occured while establishing a
connection to SQL Server. The server was not found or is not accessible.
Very that the instance name is correct and that the 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 1326)
The user name or password is incorrect
The username and password work fine when they are used locally. Have tested Windows Auth locally, sql user remotely (we don't have a domain)
In SQL Server Configuration Manager > Sql Server Network Configuration > Protocols for MSSQLServer > TCP/IP > IP Addresses everything appears correctly configured. The IPv6 IPv4 addresses are correct, and IPAll has the correct port (default 1433)
The server can ping multiple hosts on the network. They can ping it back. It's only a single non-routeable subnet. 192.168.0.*
The name of the pc matches the name of the sql server from SELECT ##SERVERNAME
The server version is 10.50.6000 which maps to SQL Server 2008 R2
First of all 1433 Port allow in Firewall (Inbound/Outbound rule)
After then try login with
ServerName: IPAddress\InstanceName,1433
Authentication : SQL Server Authentication

Connect to SQL Server 2016 via Putty/SSH

I have an SSH tunnel established to my Server using Putty. I have set up two tunnels:
L3407 => 192.168.100.107:3389
L31433 => 192.168.100.107:1433
I can successfully RDP into the server using "localhost:3407". However, when I open SSMS and try using "localhost,31433" it won't connect. The error I get reads:
"A network-realted or instance-speciffic error occured while establishing a connection to SQL Server. The server was not found or was not accessible. Verify the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The remote computer refused the network connection.) (Microsoft SQL Server, Error: 1225)"
I've verified that TCP/IP is turned on in SQL Server Configuration Manager, and the IP addresses are setup. I have checked the logs on the SQL Server, and I have:
- Server is listening on [127.0.0.1 <ipv4> 1434]
- Server is listening on [::1 <ipv6> 1434]
- Server is listening on ['any' <ipv4> 1433]
- Server is listening on ['any' <ipv6> 1433]
I can connect to SSMS on the server using the machine name (named pipes),(LOCAL), localhost, 192.168.100.107, or the public IP. And if I open a hole in the Firewall for port 1433, then I can connect locally using ":1433". (Of course I almost immediately start seeing hacking attempts, so it has to be turned right back off.)
Based on the error I would think that the server is blocking it somehow, but the local Firewall is off and the hardware Firewall logs no attempts for RDP or SSMS (as expected, since it is going through the tunnel).
I am lost on what else to try. Anyone have any ideas?

Allow SQL Server Remote Connection

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.

SQL Server: error when connecting

The application I'm using tries to connect SQL Server named instance running on a dedicated database server. Here's the error I'm getting:
The TCP/IP connection to the host <instance_name>, port 1433 has failed. Error: Connection refused: connect.
Is the firewall blocking my access or what? Should I dedicate a different port for this application?
The error refused connect implies that your connection does not have permissions to connect to this instance of SQL Server.
Are you using Windows Authentication or a SQL Server Login?
For troubleshooting guidelines see: Troubleshooting Server and Database Connection Problems

Remote login to SQL Server Express 2008

I am remotely accessing SQL Server Express 2008.
I have turned on service "SQL Server Browser"
I have turned on service "SQL Server (SQLExpress)"
I have enabled TCP/IP and set dynamic ports to blank and tcp port to 1433 in properties
I can connect localy(using ip) so my credentials are correct.
I have a exceptions record in my windows firewall setting port 1433 as open.
I have performed a system reboot making all services are still turned on.
After i try and connect via a remote computer I get this error.
Cannot connect to XXX.XXX.XXX.XX
===================================
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)
------------------------------
Error Number: 3
Severity: 20
State: 0
your ideas and solutions will be greatly appreciated.
KJ
Edit
Hi and thanks for the quick responses. At present there is no connection string. I am trying to connect using: SQL Server Management Studio 2008
Edit 2
Hey Nick.
I am connecting using SERVERNAME\SQLEXPRESS I turned off windows firewall off and still there was no joy.
I tried adding the port like you suggested:
===================================
Cannot connect to XXX.XXX.XXX.XX, 1433.
===================================
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: TCP `Provider, error: 0 - No connection could be made because the target machine actively refused it.) (.Net SqlClient Data Provider)`
please show us the connection string in you are using to connect to the server with.
If your connecting using the instance name. eg. SERVERNAME\SQLEXPRESS then you will need to open up your firewall for the SQL Browser service i.e. UDP port 1434.
Alternatively, try using the port in your connection string and forget the instance name. Eg. in SSMS you can connect using SERVERNAME,1433 where 1433 is the port you've specified sql server listens to.
You say you have configured TCP/IP but your connection error message says this:
provider: Named Pipes Provider
Update
It appears you have one protocol enabled on Sql Express and are trying to connect with another via Sql management Studio. You need to connect with the TCP provider or enable Named Pipes on your Sql Server Express Configuration.
To connect with TCP, in Sql Management Studio click the Options button on the login page. This will take you to a Connection Properties page where you can select the provider. The Network protocol is probably set to default or Named Pipes at the moment and it needs to be changed to TCP.
Alternatively, in Sql Server Configuration Manager, enable Named Pipes in Protocols for Sql Express.

Resources