I'm having the below error when trying to connect to an SQL DB:
"Data Source=***.***.***.***; Initial Catalog=DbName;Persist Security Info=True;User ID=****;Password=****;"
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)
"Network Library=DBMSSOCN; Data Source=***.***.***.***,1433; Initial Catalog=DbName;Persist Security Info=True;User ID=****;Password=****;"
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 - The wait operation timed out.)
I've looked through plenty of resources online though still unable to resolve this
Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?
The top connection string is obtained from Server Explorer and has fully expected connectivity, the latter to ensure it wasn't looking for a local DB.
We've this connection string as shows and working in other non-WebApi 2.0 projects which has connectivity to the DB
I've created a new DB using RDS in AWS too and having the same errors.
I've tried recreating the whole project as shown here (without any models) with the same errors too.
Any help in getting this resolved would be greatly appreciated
Edit, for clarity:
Console App, ConnectionString1 : Connects
Console App, ConnectionString2 : Connects
Web API, ConnectionString1 : Errors
"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)"
Web API, ConnectionString2 : Errors
"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 - The wait operation timed out.)"
.
var connectionString1 = "Server=***.***.***.***;Persist Security Info=True;User Id=****;Password=****"; //just for convenience
var connectionString2 = "Server=***.***.***.***,1433;Persist Security Info=True;User Id=****;Password=****";
var connection = new System.Data.SqlClient.SqlConnection(connectionString);
try
{
connection.Open();
}
catch (Exception ex)
{ }
finally
{
connection.Close();
}
Having BitDefender installed locally restricted traffic and the 500's when using IIS. You can white-list ports though this needs to be done through requests to BitDefender or get a decent AV where you can do this yourself.
Related
When I try to connect to SQL Server by SSMS via VPN, it works fine. When I try to connect to the LAN via Ethernet, I get
TITLE: Connect to Server
Cannot connect to AYWCSSQL27\SQLS302, 1984.
------------------------------ 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: TCP
Provider, error: 0 - The wait operation timed out.) (Microsoft SQL
Server, Error: 258)
For help, click:
https://learn.microsoft.com/sql/relational-databases/errors-events/mssqlserver-258-database-engine-error
The wait operation timed out
When I try to open SQL Server 2017 Configuration Manager, I get the following:
Any help would be appreciated.
Sometimes following error happening in windows application. The error is like
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)
I am having more than 50 forms in my application and most of the times there is no error. But sometimes, there is an error like this and when I am trying to connect sql its works fine.
I am trying to connect the sql server on my local computer from azure timer trigger function using Hybrid connection with Service Bus and getting the error as
"Exception while executing function: Functions.testConnection. mscorlib: Exception has been thrown by the target of an invocation. .Net SqlClient Data Provider: 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). Access is denied.2017-06-28T11:20:00.015 Function started"
And this is the code:
sqldb_connection value is :
Data Source=103.249.120.30 ;Initial Catalog=databasename;User ID=id;Password=password;
I am building a web application so I want to connect the web application on local machine to a company SQL Server. When copying the connection string from the same web application sitting on the server to my local web config I get the following error
"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)".
Your help will be appreciated....
WPF with local database application
I was about to start but I faced this problem
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)
I searched alot to found that the error will be in the connection string
but I'm using the connection string from application settings which done by the wizard
using ( SqlConnection _SqlConnection = new SqlConnection ( Properties . Settings . Default . DatabaseConnectionString ) )
{
_SqlConnection . Open ( ); // <= Error Occurs Here
_SqlConnection . Close ( );
}
Error :
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)
You're using the wrong type of connection object.
SqlConnection is for the grown up SQL server, not for SQL Server Compact. connectionstrings.com has the connection strings you need. For the connection object itself I believe you need the SqlCeConnection class (add a reference to System.Data.SqlServerCe).