Just a day ago, I was doing small attempt to connect to my local SQL Server using IP 127.0.0.1. The IP is of my local machine and SQL Server is installed on the local box as well. However, whenever I try to connect to the server it gave me following strange error.

Cannot connect to 127.0.0.1.
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)
The reason was indeed strange as I was trying to connect from local box to local box and it said my login was from an untrusted domain. As my system is not part of any domain, this was really confusing to me. Another thing was that I have been always able to connect always using 127.0.0.1 to SQL Server and this was a bit strange to me. I started to think what did I change since it last time I connected to SQL Server. Suddenly I remembered that I had modified my computer’s host file for some other purpose.
Solution:
I opened my host file and immediately added entry like 127.0.0.1 localhost. Once I added it I was able to reconnect to SQL Server as usual. The location of the host file is C:\Windows\System32\drivers\etc. You will find file with the name hosts in it, make sure to open it with notepad.

If you are part of a domain and your organization is using active directory, make sure that your account is added properly to active directory as well have proper security permissions to execute the task.
Reference : Pinal Dave (http://blog.SQLAuthority.com)












I was laughing because you put in the loop back IP as your IP. Probably you should do a IPCONFIG and put in that IP as your IP.
You can keep laughing but there is nothing wrong with using loopback IP (for localhost) in the host file.
Hi Pinal
I do not think doing an entry into hostfile is a solution. 127.0.0.1 is loopback IP, it must work without an host file entry. It is working for me on many server.
Dear Sir, I followed your instructions but not resolved. I am getting same error which you have mensioned.
Example, I have 3 machines; windows7, and two machines of windows server 2003. I can connect SQL server from windows server2003 to another windows server 2003 machine and windows7 machine. But problem is I unable to connect SQL Server from windows 7 machine. what should I do??
Same error here as well. Solution did not work.
I figured this out…
I was connecting to another name specified in my hosts file as 127.0.0.1
The reason being, I work in a dev enviroment where our SQL Connection strings are all setup as something like my_dev_sqlbox. The entry looked like this:
127.0.0.1 localhost
127.0.0.1 my_dev_sqlbox
my_dev_sqlbox was giving me the error. However, if I enter it like this it works:
127.0.0.1 localhost
127.0.0.1 my_dev_sqlbox localhost
TThe error message, at least, suggest two things
i. A name resoultion trouble.
ii. lock out account. I had this issue with some
jobs and the problem was the account was lock out.
The local host was already in the host file and adding the machine name to the host file did not help either. In my case I found out that VPN software was causing the issue. Since it was a local database and a local excel file I was uploading, I simply closed the VPN connection and it worked.
Iwas having this problem when connected to VPN. I wanted to use a local copy of a network DB for development and permissions in the DB were domain controlled, so I needed the VPN connection. Adding the local host entries suggested resolved the issue.
127.0.0.1 localhost
127.0.0.1 mycomputername
127.0.0.1 mycomputername localhost
strangely I was only having this prioblem with SSMS 2012, 2008 worked fine?
Hello Pinal,
We have an scenario where the SQL server is in different domain (ex. A) altogether and trying to access the sql instance from domain B. there is no domain level trust put in place but when manage to launch the SSMS using run as and providing the domain A user credentials it allows. But unable to connect using domain B. we are able to successfully add the Domain B user account as a login to the SQL server on Domain A, but no luck.
Any workaround or solution you suggest for this scenario?
Domain B is our development environment domain
Domain A is our Production environment domain where end users / developers are in
All – Appreciate your views on this?