简体   繁体   中英

Mercurial hg clone error - “abort: error: Name or service not known”

I have installed the latest hg package available for Fedora Linux. However, hg clone reports an error.

hg clone http://localmachine001:8000/ repository

reports:

"abort: error: Name or service not known"

localmachine001 is a computer within the local network. I can ping it from my Linux box without any problems. I can also use the same http address and browse the existing code. However, hg clone does not work.

If I execute the same command from my Macintosh machine, I can easily clone the repository.

Some Internet resources recommend editing .hgrc file, and adding proxy to it:

[http_proxy]
host=proxy:8080

I have tried that without any success. Also, I assume that proxy is not needed in this case, since the hg server machine is in my local network.

Can anyone recommend me what should I do, or how could I track the problem?

Thank you in advance.

The problem is (likely) that your http proxy is not able to:

  1. Resolve localmachine
  2. Reach your (or localmachine 's) local IP, even if it could resolve 'localmachine' to your correct local address.

First, make sure nothing on your side (iptables / NAT / firewall) is preventing egress or ingress on the proxy port. If it works if you're root, that's the problem - work backwards from there.

Its also conceivable that your proxy is mangling the responses from the remote HG sufficiently to confuse Mercurial, but not your browser. In either case, its best to just go around the proxy if the HG is on the local (localhost/lan) network.

Fortunately, the [http_proxy] directive supports bypassing the proxy for certain host names, which is ideal for dealing with stuff on the same side of a NAT, or hosts that only exist on one machine (eg resolved via /etc/hosts.) This saves the pain from having to edit .hgrc every time you need to change the behavior.

See the documentation , or simply make your .hgrc look something like this:

[http_proxy]
host=proxy:8080
no=localmachine,192.168.1.123,192.168.1.234,...,...

The operative directive of course being no . I'm not sure if you can use wildcards when specifying the hosts (I don't use the proxy feature, so no way of testing that .. and its not specified in the documentation). You might try experimenting with that, eg 192.168.1.* and let us know if that works as well.

Anyway, for the terminally lazy (or people in a rather big hurry), the related section of the documentation linked above:

http_proxy

Used to access web-based Mercurial repositories through a HTTP proxy.

host
    Host name and (optional) port of the proxy server, for example "myproxy:8000".
no
    Optional. Comma-separated list of host names that should bypass the proxy.
passwd
    Optional. Password to authenticate with at the proxy server.
user
    Optional. User name to authenticate with at the proxy server.

Running hg as root solved the problem for me. But still don't know why.

This happened to me when my DNS name server settings weren't configured. Try to ping the remote repository host and try to ping some well-known host eg google.com . If it doesn't work, fix your DNS settings.

The error is because of DNS, add entry into /etc/resolve.conf .

$ cat /etc/resolve.conf
search xyz.com abc.com   --> DOMAINS
nameserver 10.192.160.12 -->DNS1
nameserver 10.193.180.23 -->DNS2

This enables to reach local machine by name, & hence clone will be successful.

Clone and the web interface use exactly the same mechanism, so it's very odd that you can see the repo at http://localmachine001:8000/ but you can't clone from it.

What about trying to go to that machine by IP address? Something like hg clone http://192.168.0.4:8080 and see what happens?

Any more detail with --debug ?

I Faced same issue,

To resolve this issue i just disconnected my internet from my laptop and reconnected again

Thankyou Happy coding ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM