Cannot connect to SQL2008 in Virtual PC from host Windows7

sql-server-2008virtual-machinesvirtualizationwindows-server-2008

I have SQL2008 installed on Server2008 in a Virtual Machine (using Microsoft Virtual PC). My host OS is Win7 X64.

I've installed SQL Enterprise Manager on the host, but although it sees my SQL server when I browse for servers, it will not connect – giving Error 40 could not open a connection (as described here).

I've done all the basic stuff I can think of:

  • I can connect to the instance using Enterprise Manager locally on the server.
  • Remote connections are enabled using TCP and Named Pipes
  • TCP is using port 1433, port 1433 is allowed through both firewalls (and disabling firewalls completely makes no difference)
  • SQL Server Browser service is running

The Virtual Machine is using the Shared Networking (NAT) connection in Virtual PC, and can connect to the internet, I can ping google and the host. My host can not ping the server though.

EDIT – I think this is a Virtual Machine network issue, not a SQL one.

The Virtual Machine (Win2008) CAN ping the host, but the host CAN'T ping the Virtual Machine.

Is this to do with the NAT connection that's used by the Virtual PC? I don't know a lot about how the Network Sharing works in MS Virual PC…

Best Answer

OK - so it was to do with the NAT I was using. Here's my solution, with some description, if you're having the same problem.

  1. Using NAT means that all of your Virtual Machines will be able to talk to each other, but you won't be able to communicate with them externally.
  2. Using the Host's network card for the Virtual PC didn't work for me, but I gather this wouldn't allow communication between Virtual Machines (correct me if I'm wrong).
  3. The solution, and what fixed my issue, is to install and use the Microsoft Loopback Adapter.

Summary of steps required:

  • Install Loopback Adapter on Host
  • Configure Loopback Adapter to use static IP on Host
  • If internet connection needed - allow Loopback Adapter to share your existing network connection
  • Set Virtual Machines to use Loopback Adapter instead of NAT or other network card
  • Allow Virtual Machines to obtain IP automatically.

Here's a link with further details of install and configuration of Loopback Adapter. This helped me enormously.

Related Topic