Title: Error TF31004 connecting VS2012 to TFS
Tags: visual-studio-2012;tfs
Question: I am trying to setup a new connection to TFS with VS2012. Early on I was able to add my TFS server and, using the Microsoft Git Provider, clone a copy of the remote repository from within Visual Studio. Later, as I was fiddling with things in Team Explorer trying to find the branch I wanted to use, something broke. My local repository remains, but my connection to the remote repository was somehow corrupted, as evidenced with this error:

```
  TF31004: Unexpected error encountered while connecting to Team Foundation Server at http: //my.server.com:8080/tfs. Wait a few minutes and try again. If the problem persists, contact the server administrator ok help
```

Things I have tried to resolve this:


Wait and try again (as the error message suggested).
Restart Visual Studio.
Reboot my machine.
Reboot TFS server.
Use system restore to revert back before I installed msysgit and Microsoft Git Provider, or had attempted to connect to the TFS server.
Review the MSDN help for the error (see below).
Search Stack Overflow (found one other related issue but did not seem to apply).
Tried devenv /ResetSkipPkgs
Tried devenv /setup
Re-install Team Explorer for VS2012.
Clear IE cookies (per this post).
Clear TFS caches (per this post).


The help page offers these tidbits, but none of them seem likely given that I had, as I said, the connection working at one point:


The version of Team Foundation running on the local computer does not match the version running on the Team Foundation Server server {name}.
The server returned HTML content instead of XML content.
The required Web service on the server could not be found.


Any ideas would be appreciated!

Comment: You said you're using the git provider - is this the Visual Studio Tools for Git extension? If so, have you got the latest version installed? Also are you connecting to the hosted TFService and a git repository on the server or are you using tf-git with TFVC?

Comment: Yes, the git provider is from Visual Studio for Git, version 780-626-5613, installed yesterday. As to your last question, I am not quite sure but I believe it is the former (i.e. *not* using tf-git or TFVC, as I have not heard of those before :-).


Here is another answer: I have had an exactly the same problem.

My solution was to clear all the credentials in the Windows Vault (Credential Manager residing in the Control Panel).

I have no idea why the credentials did get messed up.

Comment for this answer: @Bill Hey. I too have the same problem. Can you tell me where to change the settings from ??
Comment for this answer: This worked for me, although I did not need to clear all the credentials in the Windows Vault.  All that I needed to do was remove the entry for the server I was trying to connect to.  I had reinstalled the server and kept the same name - that probably caused my credentials to get messed up
Comment for this answer: I had to clear two settings, one was for the git:http://tfs_server... and the other just the plain http://tfs_server.  Than I had to reboot Visual Studio.  After that, I was able to connect.  +1

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:10/01/13', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<visual-studio-2012><tfs>', 'Title': 'Error TF31004 connecting VS2012 to TFS', 'ViewCount': 2073, 'id': 19125062, 'user_AboutMe': '<p>• Software designer/architect, application/website developer, author, educator--see full <a href="http://cleancode.sourceforge.net/wwwdoc/about.html" rel="nofollow noreferrer">brand page</a>.\n<br/>\n• Broad exposure to diverse firms from R&amp;D at a Fortune 500 firm to principal software designer at a tiny startup company.\n<br/>\n• Worked on projects including: wep apps, content management systems, laser control, multi-user systems, database tools, color laser printer firmware.\n<br/>\n• Over 100 articles published on Simple-Talk.com and DevX.com covering <em>topics</em> (TDD, code review, source control, documentation, debugging, code smells, usability, visualization, testing) and <em>technologies</em> (C#, PowerShell, .NET, LINQ, JavaScript, AngularJs, XML, WPF, WinForms, database) -see <a href="http://cleancode.sourceforge.net/wwwdoc/articles.html" rel="nofollow noreferrer">full article list</a>.\n<br/>\n• Open-source endeavors:\n<br/>&nbsp;&nbsp;(1) <a href="https://github.com/msorens/SqlDiffFramework" rel="nofollow noreferrer">SqlDiffFramework</a>, a database comparison tool for comparing heterogeneous data sources.\n<br/>&nbsp;&nbsp;(2) <a href="https://github.com/msorens/DocTreeGenerator" rel="nofollow noreferrer">DocTreeGenerator</a>, combines help pages of your PS cmdlets into a tree-structured HTML web site.\n<br/>&nbsp;&nbsp;(3) <a href="https://github.com/msorens/MonitorFactory" rel="nofollow noreferrer">MonitorFactory</a>, a PowerShell framework to generate near-real-time monitors for any data resources.\n<br/>&nbsp;&nbsp;(4) <a href="https://github.com/red-gate/XmlDoc2CmdletDoc" rel="nofollow noreferrer">XmlDoc2CmdletDoc</a>, generates individual help pages for binary PowerShell cmdlets.\n<br/>&nbsp;&nbsp;(5) collection of developer tools/libraries in several languages (see <a href="http://cleancode.sourceforge.net/wwwdoc/APIbookshelf.html" rel="nofollow noreferrer">API bookshelf</a>); \n<br/>\n• Taught at community colleges and at University of Phoenix.\n<br/>\n• Member LinkedIn ( <a href="http://www.linkedin.com/in/michaelsorens" rel="nofollow noreferrer">http://www.linkedin.com/in/michaelsorens</a> )</p>\n', 'user_AccountId': 40000.0, 'user_DisplayName': 'Michael Sorens', 'user_Reputation': 34363.0, 'user_Views': 2047.0, 'user_id': 115690.0}}