SharePoint Development: Cannot connect to the targeted site


Do you have your SharePoint 2013 / Visual Studio 2012 development environment up and running ? If so, you might encounter the following error when you create a new SharePoint Project and enter the URL to your site:

Cannot connect to the targeted site

Cannot connect to the targeted site. This error can occur if the specified site is not hosted on the local system. SharePoint solutions work only with locally-installed versions of SharePoint Foundation or SharePoint Server. Remote development is supported only for apps for SharePoint 2013.

If you – like me – registered the site URL in DNS (local DNS on development machine) then you’ll get this error. It seems that Visual Studio looks at the hosts file (C:\Windows\system32\drivers\etc\hosts) for fully qualified names instead of DNS.

DNS Manager

Once you add the site’s URL to the hosts file (either to 127.0.0.1 or the local IP of the development machine) all is good and Visual Studio will connect just fine.

HOSTS file

Hope this helps!

 


Links to this post

Comments

Thursday, 21 Feb 2013 06:56 by Judah Townsend
You are awesome and thanks for advising to the correct direction and giving great tips about how to solve this Error.

Monday, 18 Mar 2013 12:26 by Colt Kline
This is nice blog and helpful information for SharePoint developer.thanks for sharing this post.

Friday, 30 Aug 2013 12:18 by Sagar K
Thanks. this is nice blog to refer. Resolved my problem. Hope MS will fix this upcoming.

Saturday, 31 Jan 2015 03:35 by kolika chan
i'm new to share point development . i'm using office 365 online with Vs 2013 ( i have Vs 2012 installed also and it working fine ) and i got this error. how can i change my hosted file with IP address ?

Sunday, 1 Feb 2015 04:45 by Steven Van de Craen
Hi Kolika, are you running VS2013 RTM or with an update? Which build number? I'd expect this issue to have been resolved by now...

Wednesday, 6 May 2015 09:10 by washbucket
This is all fine and dandy, the only problem is it seems to only work the first time around. We set this up on our dev server for SharePoint and it worked fine. Then we logged off the server, and when we came back in we were back to the same error message....

Monday, 11 May 2015 01:55 by Steven Van de Craen
Hi washbucket, I don't get that behaviour. Is your hosts file reset after logging in again?

CAPTCHA Image Validation