I'm having trouble accessing ELPA on my Mac from behind a corporate proxy. Emacs 27.1.

I have http_proxy and https_proxy configured appropriately (I've also tried setting url-proxy-services).

From Emacs (M-x package-refresh-contents):

Using a proxy for https...
Contacting host: elpa.gnu.org:443
elpa.gnu.org/0 nodename nor servname provided, or not known
Package refresh done
Failed to download ‘gnu’ archive.

From Terminal:

hostname:~ 000$ gnutls-cli -V --ca-verification --x509cafile=/tmp/master.pem elpa.gnu.org
Processed 205 CA certificate(s).
Resolving 'elpa.gnu.org:443'...
Cannot resolve elpa.gnu.org:443: nodename nor servname provided, or not known

hostname:~ 000$ nslookup elpa.gnu.org
Server:     XXX.XXX.XXX.XXX
Address:    XXX.XXX.XXX.XXX#53

** server can't find elpa.gnu.org: NXDOMAIN

It looks like gnutls and nslookup are having trouble resolving the domain (nodename nor servname provided, or not known is the same error that Emacs is throwing).

However curl has no issues:

hostname:~ 000$ curl elpa.gnu.org|head
<!doctype html>
        <title>GNU Emacs Lisp Package Archive</title>

What am I missing?

  • Accroding to your last curl command, plain HTTP works, so you can 1) try curl elpa.gnu.org to see if it works too, according to my knowledge, with HTTP proxy, the local client doesn't need to resolve the domain, it sends GET http://elpa.gnu.org/ HTTP/1.1 to the proxy server 2) ask package.el to use HTTP, instead of HTTPS, GNU Elpa supports both.
    – xuchunyang
    Aug 20, 2020 at 3:53
  • Using http makes no difference. Aug 23, 2020 at 19:28
  • 1) use http instead of https for ease of debug 2) your network can't access elpa.gnu.org, and your above curl is indeed using your proxy, and your proxy does work, right? 3) "elpa.gnu.org/0 ... or not known" suggests something is wrong with your proxy setting, since you're using proxy, Emacs won't connect to elpa.gnu.org, it should ask your proxy to do. and where does the port number 0 come from? 4) here is an example setting, (setq url-proxy-services '(("http" . "localhost:1234") ...)) 5) you can test your proxy via curl -v -x http://localhost:1234 example.com
    – xuchunyang
    Aug 23, 2020 at 20:00

2 Answers 2


I was able to work around this issue by using Squid as described here. Note that I still see the elpa.gnu.org/0 nodename nor servname provided, or not known error.


Emacs package.el supports local package repo.

So here is the solution,

(setq package-archives '(("myelpa" . "~/myelpa/")))
  • Unfortunately when you run the alpa-mirror package (following the instructions) in a proxy environment it doesn't work.
    – razeh
    Aug 11, 2022 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.