I just did a clean install of emacs 26.1 on multiple computers running different OS (Ubuntu, Mint, Windows), and for some reason I cannot update my packages using M-x refresh-package-contents. I've also re-installed emacs25 through apt with no change in results. Emacs gets caught in an infinite loop trying to connect to elpa or Melpa, with the message:

Contacting host: elpa.gnu.org:443

For more information, here is my init file:

(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  (when no-ssl
    (warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
  ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
  (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
  (when (< emacs-major-version 24)
    ;; For important compatibility libraries like cl-lib
    (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))

On ubuntu i'm getting:

Error retrieving: http://elpa.gnu.org/packages/archive-contents (error connection-failed \"failed with code 113\" :host \"elpa.gnu.org\" :service 80)")

I should note that I am not using a proxy, and I am on a home network. I also know that gnuTLS is properly installed on the windows machine, as it came packaged with emacs 26.1. You might see similar questions on the forum already, but they do not have solutions that fit my needs.


As Nega suggested, I ran an uninitialized instantiation of emacs and tried to manually update the packages. Here are the contents of my Messages buffer after:

Loading 00debian-vars...done
Loading /etc/emacs/site-start.d/50cmake-data.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:80
Failed to download ‘gnu’ archive.
Importing package-keyring.gpg...done
You can run the command ‘list-packages’ with M-x l-pac RET
Package refresh done
error in process sentinel: Error retrieving: http://elpa.gnu.org/packages/archive-contents (error connection-failed "failed with code 113
" :host "elpa.gnu.org" :service 80)
error in process sentinel: Error retrieving: http://elpa.gnu.org/packages/archive-contents (error connection-failed "failed with code 113
" :host "elpa.gnu.org" :service 80)
Mark set

After debugging (list-packages) again, this is the backtrace:

Debugger entered--Lisp error: (error "Error retrieving: http://elpa.gnu.org/packages/archive-contents (error connection-failed \"failed with code 113
\" :host \"elpa.gnu.org\" :service 80)")
  signal(error ("Error retrieving: http://elpa.gnu.org/packages/archive-contents (error connection-failed \"failed with code 113\n\" :host \"elpa.gnu.org\" :service 80)"))
  #[257 "p\306\307!\210\310\311!r\211q\210\312\313\314\315\316!\317\"\320$\216\3211R
url-http-async-sentinel(#<process elpa.gnu.org<1>> "failed with code 113\n")
  • elpa.gnu.org isn’t exactly five 9’s stable. Try it in your web browser. If it doesn’t work there it won’t work in Emacs. Try again in a hour.
    – nega
    Feb 23, 2019 at 22:38
  • Thanks for your comment So it does work in my browser. Unfortunately, I've been at this for two weeks :\
    – Lee Jordan
    Feb 23, 2019 at 22:52
  • FYI, it's helpful if you post your code as a block of text, instead of an image. Readers can then cut-n-paste your code to try it out.
    – nega
    Feb 23, 2019 at 23:37

2 Answers 2


This problem was solved by forcing emacs to use https instead of http. For some reason, emacs is using http as default instead of https.

Steps to solve:

(customize-variable RET package-archives)

changed http to https in url fields

I wonder why emacs would use http as a default?...

  • 1
    Glad you worked around it! FYI in my Emacs nightly we now have (defcustom package-archives `(("gnu" . ,(format "http%s://elpa.gnu.org/packages/" (if (gnutls-available-p) "s" "")))) Similar to your original init code. You should have a sane default the next time you update your Emacs.
    – nega
    Feb 24, 2019 at 15:18

When in doubt, simplify. Start your Emacs with emacs -Q to disable initialization. Then in the *scratch* buffer, evaluate the following lines by hitting Ctrl+j after each lisp line. Afterwards your *scratch* buffer will look like:

(require 'package)

Then do Meta+x list-packages. This will bring you to the familiar package menu/interface. From here you should be able to successfully install a package. If not:

  1. inspect the contents of the variable package-archives
  2. look at the contents of the *Messages* buffer
  3. do Meta+x toggle-debug-on-error, and run list-packages again.
  • Thanks for your suggestions and tips! I made the proper edits to my question and followed your instructions. I appended the results in the original post (to no avail, unfortunately =( ).
    – Lee Jordan
    Feb 24, 2019 at 8: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.