I have an asp project which was working correctly. I have enabled https in iis and for connections through https it works perfectly.
However, if I try to access via http, it finds a problem when making a
Connection.Open() and it shows me a log with an error related to the network.
The connection string is
<connectionStrings> <add name="conn" connectionString="Data Source=XXX.XXX.X.XXXSQLEXPRESS;Initial Catalog=database;User id=userName;password=pass"/>
I use the key
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
And it fails when it runs
This is the error that it prints:
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: Interfaces de red SQL, error: 26 – Error al buscar el servidor o instancia especificado)
English translation from google translate
Instance-specific or network-related error while establishing a connection to the 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 support remote connections. (provider: SQL network interfaces, error: 26 – Failed to find the specified server or instance)
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
If you are remotely connecting to a database on another device, you need to check the following points. Your problem is most likely caused by one of them.
- Add a specified database at the end of the connectionstring.You might be able to leave out the database from the connection string, but in that case, that connection will be made to the configured default database of the login that’s connecting to SQL Server (and that default database must exist at the time the connection is made)
This is the standard connection string format:
var conn = new SqlConnection(); conn.ConnectionString = "Data Source=.SQLExpress;" + "User Instance=true;" + "User Id=UserName;" + "Password=Secret;" + "AttachDbFilename=|DataDirectory|DataBaseName.mdf;" conn.Open();
- Turn on the Windows service called “SQL Server Browser” and start the service.
- In the Windows firewall, enable incoming port UDP 1434 and TCP 1433. It is better to add port after IP in the connection stringIt is better to add port after IP in the connection string.
Every time client makes a connection to SQL Server named instance, we will send a SSRP UDP packet to the server machine UDP port 1434. We need this step to know configuration information of the SQL instance, e.g., protocols enabled, TCP port, pipe name etc. Without these information, client does know how to connect the server and it fails with this specified error message.
- In SQL Server Configuration Manager, enable TCP/IP protocol for port 1433
check he instance name in object explorer in mssql server
both should match