Problem
When making calls to a SQL database from a WCF service we receive 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
Our Setup
We have a WCF service hosted on an internal server behind the firewall. That service makes calls to SQL. When making calls to the WCF service from inside the firewall, the service can communicate with the SQL server fine. We moved site outside the firewall and the network guys gave me a port to use for talking between the site and the WCF service. When making calls to the service from the site outside the firewall, the service gets an error when connecting to the database. We are using SQL authentication in the connection string to connect to the database.
Connection String Example:
Data Source=SQLServer;Initial Catalog=Database;
Persist Security Info=True;
User ID=username;Password=userpass