2

I was wondering if I can get some help with a problem I'm having.

I'm using requests to pull some data from an api for a web app that I'm deploying on Heroku. On my local computer I have no problem connecting to the API and pulling data down, but when I deploy to Heroku it won't work. (The same thing happens when I try testing on Cloud 9 IDE)

Example Code below:

import requests


email = 'example@example.com'
url = 'https://api.example.com/'
auth = ('example', 'example')
headers = {'Accept': 'application/json', 'content-type': 'application/json'}
params = {'emailaddress': email}

r = requests.get(url+'customer.svc/search', params=params, auth=auth, headers=headers)

It's very basic, but I just can not get it to work.

Everytime I try to connect I get the error:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /customer.svc/search?emailaddress=example%40example.com (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)

I'm new to Heroku, so this might be prety basic. What am I missing?

Edit:

It seems the error only happens when I deploy my code. I've tried the code on several machines and I have no trouble with the request. I wonder if it has something to do with the connection back to my Heroku app?

Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
  • Heroku used to block out-bound HTTPS connections. I'm unsure if they still do. Can you do `heroku run bash` and open a python interpreter and see if you can contact a different site with `https`? – Ian Stapleton Cordasco Dec 12 '14 at 17:15
  • Possible duplicate of [What does "connection reset by peer" mean?](http://stackoverflow.com/questions/1434451/what-does-connection-reset-by-peer-mean) – ivan_pozdeev Nov 06 '15 at 00:00

0 Answers0