Request.el “cannot create connection to api.stackexchange.com”

I'm using the request.el library (available via MELPA) to try and create a basic framework from which to start work in earnest on a Stack Exchange mode for Emacs. All I want to do is to be able to return the object as parsed by json-read to the calling function, but I can't even seem to make a connection.

I understand that to have my function return the object, the call must be made synchronously, so that is what :sync t is there for. I've considered making it an asynchronous call, but I don't think it would be beneficial considering its use-case.

At first, after I looked at the messages, I thought 'Maybe I don't have necessary binaries.' I did test request.el with some example calls that come with its documentation, and they work fine, so that's out.

I'm at a loss as to what is wrong. I don't yet have much experience, successful or otherwise, with anything dealing with a network, and don't fully understand the error message I'm getting. As far as I can tell, port 443 of the API is giving me the silent treatment, but I'm hesitant to think that's the case ;).

;; Works like a charm (defun alist-to-json (alist) "Converts the key-value pairs of `ALIST` into a JSON-friendly string: \"key1=value1&key2=value2&\"." (apply 'concat (mapcar (lambda (kv) (format "%s=%s&" (car kv) (if (stringp (cdr kv)) (cdr kv) (number-to-string (cdr kv))))) alist))) (defvar stack-api-root "https://api.stackexchange.com/2.1/") (require 'json) (require 'request) (defun stack-api-request (call keys-alist) "Makes the specified `CALL` to the Stack Exchange API with the key-value pairs given `KEYS-ALIST`. For example, (stack-api-request \"sites\" '((page . 2) (page_size . 25)))" (let* ((base-call (concat stack-api-root call "?")) (options (alist-to-json keys-alist))) (request base-call :params options :parser 'json-read :sync t)))


Debugger entered--Lisp error: (error "Could not create connection to api.stackexchange.com:443") signal(error ("Could not create connection to api.stackexchange.com:443")) error("Could not create connection to %s:%d" "api.stackexchange.com" 443) url-http([cl-struct-url "https" nil nil "api.stackexchange.com" nil "/2.1/sites?&" nil nil t nil t] #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil)) url-https([cl-struct-url "https" nil nil "api.stackexchange.com" nil "/2.1/sites?&" nil nil t nil t] #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil)) url-retrieve-internal("https://api.stackexchange.com/2.1/sites?&" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil) nil nil) url-retrieve("https://api.stackexchange.com/2.1/sites?&" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"]) url-retrieve-synchronously("https://api.stackexchange.com/2.1/sites?&") request--url-retrieve-sync("https://api.stackexchange.com/2.1/sites?&" :params "page=2&page_size=25&" :parser json-read :sync t :error (closure (t) (&rest args) (apply (quote request-default-error-callback) (quote "https://api.stackexchange.com/2.1/sites?") args)) :url "https://api.stackexchange.com/2.1/sites?&" :response [cl-struct-request-response nil nil nil nil nil "https://api.stackexchange.com/2.1/sites?&" nil (:params "page=2&page_size=25&" :parser json-read :sync t :error (closure (t) (&rest args) (apply (quote request-default-error-callback) (quote "https://api.stackexchange.com/2.1/sites?") args)) :url "https://api.stackexchange.com/2.1/sites?&" :response #0) nil nil nil url-retrieve nil]) apply(request--url-retrieve-sync "https://api.stackexchange.com/2.1/sites?&" (:params "page=2&page_size=25&" :parser json-read :sync t :error (closure (t) (&rest args) (apply (quote request-default-error-callback) (quote "https://api.stackexchange.com/2.1/sites?") args)) :url "https://api.stackexchange.com/2.1/sites?&" :response [cl-struct-request-response nil nil nil nil nil "https://api.stackexchange.com/2.1/sites?&" nil #0 nil nil nil url-retrieve nil])) request("https://api.stackexchange.com/2.1/sites?" :params "page=2&page_size=25&" :parser json-read :sync t) (let* ((base-call (concat stack-api-root call "?")) (options (alist-to-json keys-alist))) (request base-call :params options :parser (quote json-read) :sync t)) stack-api-request("sites" ((page . 2) (page_size . 25))) eval((stack-api-request "sites" (quote ((page . 2) (page_size . 25)))) nil) eval-expression((stack-api-request "sites" (quote ((page . 2) (page_size . 25)))) nil) call-interactively(eval-expression nil nil)


Contacting host: api.stackexchange.com:443 Opening TLS connection to `api.stackexchange.com'... Opening TLS connection with `gnutls-cli --insecure -p 443 api.stackexchange.com'...failed Opening TLS connection with `gnutls-cli --insecure -p 443 api.stackexchange.com --protocols ssl3'...failed Opening TLS connection with `openssl s_client -connect api.stackexchange.com:443 -no_ssl2 -ign_eof'...failed Opening TLS connection to `api.stackexchange.com'...failed <hr>

I checked to make sure that this was not a problem with cURL. The call I use for curl is

curl api.stackexchange.com/2.1/sites --compressed

From the outside looking into the request repository, request is doing this as well. I don't know what could be going wrong.


I boiled down your example to the following snippet to reproduce your problem but it actually worked. Can you try this one?

(request "http://api.stackexchange.com/2.1/sites" :parser 'json-read :params '((page . "2") (page_size . "25")) :success (lambda (&rest args) (princ (plist-get args :data))))

It should print some data to *Messages* buffer and echo area.

EDIT: It seems that the problem in your example is that you are passing string to PARAMS which takes only alist. I will change code to raise error so that it is easier to debug.


  • VBA script to copy adjacent cells if duplicate found
  • Matrix Transpose Common Lisp
  • Python shuffle list not working [duplicate]
  • Controlling the actions with org-mode
  • convert ienumerable linq list to typed list
  • Getting .htaccess file to work in subfolders
  • How to save a django model with a manyToMany Through relationship, AND regular manyToMany relationsh
  • scala groupBy class then map the results
  • Flash Button (Creating a menu page with flash buttons to open SWF Files)
  • Calling hundreds of azure functions in parallel
  • Dagger2 difference between modules and dependincies
  • How do I convert an SQL date result to British format (dd/mm/yyyy)
  • How to sort a list by Number then Letter in python?
  • Vim syntax highlighting for multiline fortran openmp directives
  • Matlab: Fundamental limitations of struct array?
  • How do I run a command just after the emacs frame has been rendered?
  • Mode-specific or buffer-local text objects in evil?
  • Consecutive calls/evaluations in a form?
  • How can I cons a list of pairs on to auto-mode-alist?
  • EMACS rebinding C-spc disable highlight of selected region
  • Append element to binary file
  • Send http request through specific network interface
  • Returning semi-unique values from a list
  • UIImageJPEGRepresentation giving 2x images on retina display
  • Android gcm notification payload vs data payload?
  • Excel Date field value differs from c# dateTime by 1 day while reading excel file with EEPlus
  • Does Context/Scoping of a SQLAlchemy Session Require Non-Automatic Object/Attribute Expiration?
  • Streaming screenshots over WebRTC as a video stream from iOS
  • Setting the run time properties on SpringApplicationBuilder()
  • Row to Column conversion in Talend
  • one Local Olampyad Questions on Informatic in 2011
  • Meteor helpers not available in Angular template
  • Why value captured by reference in lambda is broken? [duplicate]
  • How to recover from a Spring Social ExpiredAuthorizationException
  • ILMerge & Keep Assembly Name
  • Large data - storage and query
  • WOWZA + RTMP + HTML5 Playback?
  • Why joiner is not used after Sequence generator or Update statergy
  • Recursive/Hierarchical Query Using Postgres
  • UserPrincipal.Current returns apppool on IIS