1

Some insight, closed lab environment, Windows Server 2012 (host) with 2 VM's Windows 8.1 (guests) on INTERNAL Virtual Switch. Host is set as default gateway with ip 1, VMs accordingly 2 and 3. All the entities can see each other on the network, that means I can ping, tracert or share files through file sharing, moreover I can even invoke-command from every place to another.

The deal is that I've got a SQL Server Express instance (SQLEXPRESS) installed on host but I can't connect to it in Powershell from vm's using following piece of code:

$sql_Server = "HOST\SQLEXPRESS"
$sql_User = "User"
$sql_Password = "Password"
$sql_Database = "Database"
$sql_Connection = New-Object System.Data.SqlClient.SqlConnection
$sql_Connection.ConnectionString = "Server=$sql_Server; Uid=$sql_User; Pwd=$sql_Password; Database=$sql_Database"
$sql_Connection.Open()

All I've got is following error:

Exception calling "Open" with "0" argument(s): "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)"

Following your questions:

  • Firewall if off on all of them,
  • Tcp port 1433 enabled,
  • above piece of code works from host

I know not much about networks so I guessing that I'm missing something in this puzzle

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
kmaxg
  • 11
  • 2
  • SQL Server **Express** by default doesn't allow **remote connections** - those have to be explicitly allowed – marc_s Nov 30 '14 at 12:23
  • This thread may help... http://stackoverflow.com/questions/11278114/enable-remote-connections-for-sql-server-express-2012 – andyb Nov 30 '14 at 13:24
  • @andyb thanks, it was not exacly the answer but it got me to it! I had to run sql browser. – kmaxg Nov 30 '14 at 14:43

1 Answers1

0

I had to run SQL Browser service to be able to query server from VM.

kmaxg
  • 11
  • 2