Ошибка при соединении

Текст ошибки

Message: 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) Type: System.Data.SqlClient.SqlException Loc: Db.Connect

Варианты причин

The error message means that you were not able to contact SQL Server, and there are a whole number of possible reasons:

  • SQL Server is not running.
  • You have misspelled the server or instance name.
  • You are connecting from a remote machine, and there is a firewall in the way.
  • You are connecting from a remote machine, and the network is segmented.
  • You are connecting from a remote machine, and the browser service is not running and you are trying to connect to named instance.
  • You are connecting from a remote machine, but SQL Server does not accept local conncetions...

 

Варианты решения

1. Эта проблема может возникнуть, если на ПК установлено несколько MS SQL серверов. Версии MS SQL значения не имеют.

В таком случае в поле «Имя сервера» указываем имя сервера и инстанс (либо порт).

Порт можно посмотреть тут:

2. Не настроен доступ по списку портов, необходимых для работы MS SQL.

Чтобы настроить брандмауэр, необходимо разрешить трафик от NNN порта до 1433 порта и от 1433 порта до MMM, где NNN и MMM - порт с номером больше 1024. Подробнее об используемых портах здесь.

2194