SQL Server: error when connecting - sql-server

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

Related

Connect IIS in DMZ to SQL Server on intranet

I'm trying to connect IIS which is running on a server in the DMZ to a SQL Server instance on the company intranet. But, I'm getting the following error:
An unhandled exception occurred while processing the request.
Win32Exception: Access is denied.
Unknown location
SqlException: 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)
Do I need specific ports opened up on one of the servers? Or is there something else I need to do?
Considering your SQL server is running, start with the networking. On which port is your SQL instance listening (default 1433)?
If you don't know, open the SQL Server Configuration Manager (on the SQL Server). Navigate to the SQL Server Network Configuration > Protocols for %instancename% > TCP/IP > IP Addresses. Then, test if something is blocking this connection; on your IIS in PowerShell:
Test-NetConnection -ComputerName sqlservername -Port 1433
If this doesn't work, check the Inbound Rules for Windows Firewall on your SQL Server. Make sure you work on the right network profile and eventually speak to the one managing your network systems in your company.
Maybe your IIS can't resolve the SQL Servers hostname? Try using the IP and check your DNS configuration.
There might also be something off with your connection string. Mind posting it here?

AWS Schema Conversion Tool to Connect to SQL Server on localhost

Background
I have a SQL Server database on my machine, using mixed mode auth and SQL users setup on the database and mapped. When connecting via .NET app, I am able to use both windows auth and sql auth without issues. However when connecting via AWS Schema Migration tool, I am not able to connect.
Checks done:-
SQL Server Browser Service running
Port mapping left to default (1433)
TCP/IP pipeline enabled
Done both sql and windows auth
Instance name given via ##servername command as per SCT doc
Windows user given dbo and serveradmin permissions at global level
and also granted Login and DB engine connect
Ignoring the port no
Ignoring the instance name
Unable to check firewall as both SQL and tool running on same machine
Using same SCT config, I can connect to SQL Server elsewhere so drivers seem to be working.
Log message below
When only localhost provided
com.amazon.sct.dbloader.DbLoaderHandledException: Connection wasn't established. Check connection properties.
java.util.concurrent.ExecutionException: com.amazon.sct.dbloader.DbLoaderHandledException: Connection wasn't established. Check connection properties.
When name provided for machine and instance
Connection to 'jdbc:sqlserver://localhost\DESKTOP-N01JO12:1433' wasn't established. ERROR: code: 0; message: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
LOADER ERROR Error chain:
The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."
Screenshots
For AWS SCT can access SQL server, the following conditions need to be satisfied:
DB has login account and user
User have to has admin role
SQL server authentication enabled
TCP/IP cho SQL server enabled
1. DB has login account and user
You can reference in this link:
https://www.guru99.com/sql-server-create-user.html
2. User have to has admin role
You can reference in this link: https://tableplus.com/blog/2018/10/how-to-create-user-with-admin-access-in-sql-server.html
3. SQL server authentication enabled
You can reference in this link:
SqlServer: Login failed for user
Note: Remember to restart SQL server
4. TCP/IP cho SQL server enabled
You can reference in this link: https://www.youtube.com/watch?v=p9mv2RP6Tck
==> Conclusion
I see you do all the think above
Here is my connection information for SQL server on my EC2 windows server
(I can't embed picture because I don't have enough reputation point)
Perhaps you should write connection information like me
Hope this help!

Connecting to Azure DB from SQL management studio is failing MSSQLSERVER_10060

I'm trying to connect to the sql server that has been created on Azure using SQL management studio, but i'm getting the following error.
Error message: An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - 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.) (Microsoft SQL Server, Error: 10060)
I have enabled the client IP in the SQL server firewall settings.
Please let me know if anything else need to be taken cared. Thank you
To resolve this error, try one of the following actions:
Make sure that you have configured the firewall on the computer to allow this instance of SQL Server to accept connections. That is, If you are trying to connect from within a corporate network, outbound traffic over port 1433 may not be allowed by your network's firewall. If so, you cannot connect to your Azure SQL Database server unless your IT department opens port 1433. On the Azure Side, you also need to check if the NSG (associated with that subnet the Azure SQL server sitting in) allows the client IP with the specific port 1433.
Add the client IP in the SQL server firewall settings if you enable a server-level firewall.
Telnet the current IP of your Azure SQL Database server with the port to verify the network connection.
Ensure the server name you are connecting to is correct.
Check that your own firewall allows your connection across the internet to the instance.
Typically if it was the Azure firewall side, it would prompt you to add your IP to the firewall rules, provided you're connecting with an admin account.
This cause by network restriction in your lan. you can try by switching your network connnection. It worked for me.

SQL Server 2005 Remote Connection ( Over Internet )

I have installed SQL Server 2005 in mixed mode.
I am able to connect to Database "locally" i.e.
(Server-name/Instance or internal-ip/Instance) using both kinds of Authentication.
I have configured SQL Server for remote connection by following below steps
Steps:
Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer.
Turn on the SQL Server Browser service.
Configure the firewall to allow network traffic that is related to SQL Server and to the SQL Server Browser service. Ref: http://support.microsoft.com/kb/914277#method3
In addition, I have turned off my firewall.
I am able to ping my computer through the External IP.
But when it comes to connecting to sql server, its giving the error.
"TITLE: Connect to Server
Cannot connect to <ip address>\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
Please help me,
I have referred many article and tested all possible solution, but nothing seems to be working for me.
It turned out to be an issue with Port Forwarding from my Modem/Router to respective Machine IP.
To resolve this issue, I just configured my Router so that it can accept the request on some specific port [External IP:port_number] and then map that request to my machine's [Internal IP:port_number] as multiple computers were connected to a single router.
Also, please make sure that Firewall on your server is configured correctly to accept the inbound network traffic on that specific port.

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