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

31.5k views Asked by At

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!!

1

There are 1 answers

3
Willis Blackburn On BEST ANSWER

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.