web-dev-qa-db-ja.com

SQL Serverへの接続の確立中にネットワーク関連またはインスタンス固有のエラーが発生しました

Asp.net Webアプリケーションをsomee.comにデプロイしました。このサイト(ipc.somee.com)にログインするたびに、次のようなネットワーク関連のエラーが表示されます。

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)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: 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)

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the Origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 


[SqlException (0x80131904): 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)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296071
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308555
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +920
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +434
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +5311099
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +37
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +558
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +67
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1052
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +167
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +143
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +83
   System.Data.SqlClient.SqlConnection.Open() +96
   Default.log(Object sender, EventArgs e) in c:\users\sreekanth\documents\visual studio 2010\Projects\IPCWebApp\IPCWebApp\Default.aspx.cs:43
   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +124
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
25
Suresh

アプリケーションにデータベースにアクセスするための十分な権限がない場合、SQL Serverはこのエラーを起動します。このエラーにはいくつかの理由があります。このエラーを修正するには、次の指示に従う必要があります。

  1. Management Studioを使用して、サーバーからSQLサーバーに接続してみてください。 Windows認証を使用してSQLサーバーに接続する場合は、アプリケーションプールIDをサーバー管理者に設定します。

  2. sQLサーバー認証を使用する場合は、Webアプリケーションのweb.configで接続文字列を確認し、ログインを許可するSQLサーバーのユーザーIDとパスワードを設定します。

  3. 他のサーバーのデータベース(リモートデータベースにアクセス)の場合、最初にsqlサーバー管理スタジオからsqlサーバープロパティからsqlサーバーのリモートアクセスを有効にし、sqlサーバー構成マネージャーからTCP/IPを有効にします。

  4. これらすべてを行ってもデータベースにアクセスできない場合は、データベースにアクセスしようとしているサーバー形式のファイアウォールを確認し、ファイアウォールにルールを追加してSQLサーバーのポートを有効にします(デフォルトでは、SQLサーバーは1433を使用して確認しますSQLサーバーのポートSQLサーバー構成マネージャーネットワークプロトコルTCP/IPポートを確認する必要があります)。

  5. sQLサーバーが名前付きインスタンスで実行されている場合は、たとえば117.312.21.21/nameofsqlserver,1433のように、ポート番号をSQLサーバー名で記述する必要があります。

  6. Amazon awsやMicrosoft Azureなどのクラウドホスティングを使用している場合、サーバーまたはインスタンスはクラウドファイアウォールの背後で実行されるため、デフォルトインスタンスまたは名前付きインスタンスのSQLサーバーの特定のポートがある場合、クラウドファイアウォールで1433ポートを有効にする必要があります。

  7. Amazon RDSまたはSQL Azureを使用している場合、そのインスタンスのセキュリティグループからポートを有効にする必要があります。

  8. SQLサーバー認証モードでSQLサーバーにアクセスしている場合は、SQLサーバーインスタンスプロパティが「SQLサーバーおよびWindows認証モード」になっていることを確認してください。 enter image description here

    1. 一部の変更では再起動が必要になるため、プロパティに変更を加えた後、SQLサーバーインスタンスを再起動します。

さらに困難に直面した場合は、WebサイトとSQLサーバーに関する詳細情報を提供する必要があります。

45
Hiren Dhaduk