8

I'm having a problem accessing a UNC path in Windows Server 2008 using the hosts file.

My hosts file looks like:

10.x.x.x     server_1

When trying to access the unc path:

This works:

\\10.x.x.x\data

This doesn't work and says "Windows cannot find \\server_1\data")

\\server_1\data

Does anyone know how to make it resolve the path using a hosts file?

1
  • 1
    Correct me if I'm wrong, but "server_1" in your \\server_1 example isn't actually a domain name, so it wouldn't go "trough" your hosts file, would it?
    – Nanne
    Jun 22 '11 at 6:44
4

I found this article that explains what you can do to make aliases for localhost's UNC path. I was having a similar problem to the one you are having and did as the article explained, with a succesful result.

1
  • I had the exact same issue, and this worked perfectly for me. Thanks for the link.
    – Joe Enos
    Jun 2 '12 at 17:34
3

Try adding

10.x.x.x     server_1

to %SYSTEM32%\drivers\etc\LMHOSTS

(Note this file doesn't exist by default)

LMHOSTS is to unc paths as HOSTS is to TPC/IP paths.

More info here http://technet.microsoft.com/en-us/library/cc959846.aspx

2
  • 1
    In both my hosts and lmhosts file I have: 127.0.0.1 whatever. When I try to run dir \\whatever\C$\temp I get: The user name or password is incorrect.. Any idea why? When I use an IP it works fine with no prompt for password: dir \\127.0.0.1\C$\temp
    – Kip
    Mar 13 '17 at 19:39
  • I get the same error as @Kip. I'm guessing there's something in our network security preventing this because the request and actual server names don't match. I just wish I knew how to make a security exception for this one test machine.
    – Jeremy
    Aug 18 '20 at 17:40
0

Using a hosts file for resolving the hostname?
You might try removing the underscore: change server_1 to server1 or server-1. It used to be that underscores are invalid characters in system and domain names. Perhaps that's changed (although I've yet to see some underscore in the domain part of a website), but give it a try in any case.

1
  • Hi, I tried removing the underscore but its still not working. I am pretty sure it is not a name problem because I can call webservices with that name. For example: http://server_1/mywebservice/service.asmx works fine. But when using UNC file paths, it doesn't seem to be using the hosts file to resolve the name=/
    – FruitDealer
    Jun 22 '11 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy