No connection could be made because the target machine actively refused it TCP:0 Visual Studio
Asked Answered
W

1

7

Im getting this error when i try to connect to SQL from a remote computer

My firewall is disabled, my port is the default 1433, and is enable in the SQL Server Configuration Manager, also my IP on the router is enabled, and i dont use a any antivirus

This is the code that i use to connect from Visual Studio

  Dim Conn As New SqlClient.SqlConnection("Server=127.0.0.1,1433;" + "Database=Base1;Uid=Admindb;Password=2016")

Even i tried a different code

Dim cadenaConexion As String
    Dim selectSQL As String
cadenaConexion = "Server=127.0.0.1,1433;" + "Database=Base1;Uid=Admindb;Password=2016"

This is the error

*Consulte el final de este mensaje para obtener más detalles sobre cómo invocar a la depuración Just-In-Time (JIT) en lugar de a este cuadro de diálogo.

************** Texto de la excepción ************** System.Data.SqlClient.SqlException (0x80131904): Error relacionado con la red o específico de la instancia mientras se establecía una conexión con el servidor SQL Server. No se encontró el servidor o éste no estaba accesible. Compruebe que el nombre de la instancia es correcto y que SQL Server está configurado para admitir conexiones remotas. (provider: TCP Provider, error: 0 - No se puede establecer una conexión ya que el equipo de destino denegó expresamente dicha conexión.) ---> System.ComponentModel.Win32Exception (0x80004005): No se puede establecer una conexión ya que el equipo de destino denegó expresamente dicha conexión en System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)*

I don't know what to do, SQL is listening all IP's, and even the program show the server to connect in a ComboBox, but it doesn't connect it, i made a Ping to the IP server, and it works, so i dont know what kind of problem is this, HELP PLS!!

Woozy answered 31/12, 2016 at 0:49 Comment(6)
Is the database server running on the same computer as your client?Partial
Yes, in the same computer i dont have any problem, it connect perfectly, but when i try from another remote computer, it drops that errorWoozy
I don't think SQL Server Express allows external connections by default. That is the edition you are using, correct?Difficile
Is correct, i use the Express 2012, and you're right, it doesn't accept by deffault, just have to modified from the SQL Properties to allow Remote Conections, and set the TCP Port on SQL SCM, and the default port is 1433Woozy
You know, I did find a reference to SQL Server Express being configured to only accept connections from localhost by default, but the same source also said it used a random port number. Since you were using the regular 1433, I figured you had regular SQL Server and not Express.Partial
for me problem was the port number and it wasnt 1433 it was 1434 which solved issue after changing it.Defaulter
P
3

You say that you can connect to SQL Server from the same machine that's running the server but not from other machines.

There are two likely reasons for this:

  1. You are trying to connect to 127.0.0.1 port 1433 from the other machines. This will not work because 127.0.0.1 is always the local machine. When connecting from a remote client, you need to specify the IP address or host name of the machine that is running SQL Server.

  2. Your SQL Server is configured to only listen for connections on the 127.0.0.1 interface, in other words, it will only accept connections from the local machine. This is a common default configuration for database servers that are used for development, however, I couldn't find any documentation stating that SQL Server comes configured this way.

Partial answered 31/12, 2016 at 1:9 Comment(3)
Well, the IP of the SQL its 127.0.0.1, so i changed to the IP of the local Machine and it's works,but it just allowed me to connect, so i have to add a conection string to my code, because i was using only the SQL Client Conection, i just tried this before, i don't know why now it works, but im grateful, so thanks!.Woozy
Glad I could help. :-)Partial
First, I try to connect my local machine using SSMS with the local SSAS, and I get the error "No connection can be made because the target machine actively refused it 127.0.0.1 :2383 " I tried to veryfy that all services in SSAS are running . They're not, and when I try to start them, I get error 1067: "process terminated unexpectedly"Billings

© 2022 - 2024 — McMap. All rights reserved.