SQL SERVER – FIX ERROR – Cannot connect to . Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)

Just a day ago, I was doing small attempt to connect to my local SQL Server using IP 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
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 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.


I opened my host file and immediately added entry like 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 (https://blog.sqlauthority.com)

Previous Post
SQLAuthority News – A Quick Note on @Pluralsight Video – Call Me Maybe Developer Way
Next Post
SQL SERVER – Fun Post – Connecting Same SQL Server using Different Methods

Related Posts

42 Comments. Leave new

  • 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. 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

    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: localhost my_dev_sqlbox

    my_dev_sqlbox was giving me the error. However, if I enter it like this it works: localhost 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. localhost mycomputername 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?

  • Hello Pinal,

    I have this very message occurring and is becoming critical for me. Let me attempt to give the situation:

    I have MSSQL Server 2008 R2 installed for over a year on a server. I am attempting to log into SQL Server using the Computer Name via SSMS on the local server using a local windows account when I recieve the message “Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)”.

    I can login via SSMS using any other method with the same local windows account (e.g. (local), localhost,, IP address) without any issues.
    I can login via SSMS using Computer Name and SQL login account.
    I can also go to another server on the network and use SSMS to log into this SQL Server using computername and local windows account remotely.

    The only scenario which does not work is the local windows account and computer name.

    This is major issue because it is affecting my ability to set up replication.

    ANY help is greatly appreciated.


  • Hello,

    I am new to SQL DB , could you please tell me I am continuously getting “Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. [CLIENT: 172.20.*.*] ” message for different clients. we are using AD for authentication.Could you please tell me why its causing and a solution for this.


  • Hi everyone in this discussion,

    I encountered the same issue – had the same error message, but my problem was as follows:

    1. I have an application that connects with database in MS SQL Server 2008 R2 using Windows authentication.

    2. Let’s say that my server name was: SRV123 but I wanted to refer it as MyAppDBSrv so I added entry to “hosts”. When tried to log in with windows authentication there was an error mentioned.

    Solution was to add a key to windows registry as in this article:

    Hope that helps,

    • where this regiestry setting should be done ? On Client machine where application is being used? OR on SQL Server machine ?

    • This has become a nightmare for us now. At many places we have used ODBCConnection in Application to connect to Database and it’s throwing this error randomly. Please help. Thanks.

  • Hi friend,
    I have an application that connects to MSSQL.i’m using windows 7 operating system.while connect SQL server in windows authendication,it connects to windows authendication,but i can’t create a detabase in it. It shows a error message that “can’t create a database in master.access denied”.How to solve it.

  • Aw, this was a really nice post. Taking a few minutes and actual effort to generate
    a good article… but what can I say… I put
    things off a whole lot and never manage to get anything done.

  • Thank you for the great post. Someone had put the IP address with the Old server name in the host file. Once I updated it to the new server name I was able to connect to SQL server with the IP address.

  • small cushions, toys, stuffed animals – but not baby brother or sister.

    Although it usually only takes three to five days for an
    order to come in from the company, your customers will usually
    want their products immediately. Some research also
    recommend it as a aspect for the improvement of
    some forms of skin cancer.

  • jorge.gomezdanes@gmail.com
    January 22, 2014 12:28 am

    This works for me, SQL 2012 with Domain Controller. localhost mycomputername mycomputername localhost


  • Neeraj Tiwary
    April 17, 2014 11:22 am

    Thanks very much. It really helped a lot.

  • Can I able to Install MS SQL 2005 Standard Edition on Microsoft server standard 2012 R2?


Leave a Reply Cancel reply

Exit mobile version