Emacs is able to access the Internet with packages such as url.el or the W3 web browser.

Also, the Emacs Lisp Package Archive is heavily dependent on package url.el.

Now, how do I configure Emacs to use my HTTP proxy to connect to the Internet in general?

Bonus points for any help with ELPA behind a proxy.

Yes, I've had problems with HTTP proxies before.

up vote 48 down vote accepted

For w3m, this setting has worked for me:

(setq url-proxy-services '(("no_proxy" . "work\\.com")
                           ("http" . "proxy.work.com:911")))
  • @Trey Jackson: What if the proxy requires authentication? – Pedro Morte Rolo May 6 '10 at 11:27
  • 3
    If you require authentication, Emacs (at least 23.x) will ask you for your username and password, provided you have url-proxy-services set. – MikeHoss May 18 '10 at 14:46
  • 2
    Is it possible to make Emacs use IE proxy settings? – grm Oct 12 '11 at 8:17
  • 3
    @grm - see this question: stackoverflow.com/questions/10050186/… – Cheeso Apr 6 '12 at 23:03
  • 1
    Just confirmed Emacs 22 will prompt for credentials as well. Thank you @MikeHoss – justinpitts Dec 13 '13 at 15:53

I've got authorization working by:

(setq url-proxy-services
   '(("no_proxy" . "^\\(localhost\\|10\\..*\\|192\\.168\\..*\\)")
     ("http" . "proxy.com:8080")
     ("https" . "proxy.com:8080")))

(setq url-http-proxy-basic-auth-storage
    (list (list "proxy.com:8080"
                (cons "Input your LDAP UID !"
                      (base64-encode-string "LOGIN:PASSWORD")))))

Works for Emacs 24.3. It is based on non-public API tricks, so might not work in another Emacs versions...

  • legend! btw this did not work for emacs 26 on windows, but was fine for 25.3 – chris Jun 29 at 15:21
  • 1
    this worked for me (emacs 25.1.1 mingw from the gnu mirrors). If you're still playing SO -- I believe you want "10\..*" for the local host, you'll match anything that starts 10 with what you got there. – Levin Magruder Jul 28 at 1:12
  • @LevinMagruder Updated! – gavenkoa Jul 29 at 0:21

Emacs populates the url-proxy-services variable from the http_proxy, https_proxy and no_proxy environment variables if they are set.

  • This is totally the way to go – dpritch Dec 3 '17 at 0:45
  • Yes well, it doesn't work in my environment. I think they have some Bluecoat ssl cert also. How is that dealt with? – Samantha Atkins Aug 21 at 0:00

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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