'Connection reset by peer’




I wanted to check to see whether I have proper access on the backend.

I have followed these documents and have tried the methods, as well as checked past forum posts.

Each time, I see this output

`ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer’))`
ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

Even though the oauth seems correct.

Grabbing bearer token from OAUTH
{'bearer_token': 'xxxx',
 'endpoint': 'xxxx'}

I believe my yaml file is correct

  account_type: premium
  endpoint: xxxx
  consumer_key: xxxx
  consumer_secret: xxxx

Is there any guidance you can provide? The code I have used is below.

Method 1

import pandas as pd, numpy as np; from searchtweets import ResultStream, gen_rule_payload, load_credentials, collect_results
premium_search_args = load_credentials("~/.twitter_keys.yaml",account_type="premium")
rule = gen_rule_payload("#Twitter", results_per_call=100)
tweets = collect_results(rule,

Method 2

rs = ResultStream(rule_payload=rule,

tweets = list(rs.stream())

Method 3

import json
from_date = "2016-06-01" 
to_date = "2016-06-02"
rule = gen_rule_payload("#Twitter", results_per_call = 100, from_date = from_date, to_date = to_date)
rule = json.loads(rule)
tweets = collect_results(rule, max_results = 500, result_stream_args = premium_search_args)
[print(tweet.all_text) for tweet in tweets[0:10]]


Hi @kqureshi - do you have access to a developer account? AKA can you view your Search subscription here with your app name used for credentials?



Thanks for the response. Yes, I was approved yesterday and can view that dashboard


Hi @kqureshi - do you mind sharing the following:

  • what is your endpoint?
  • what version of the library are you using?
  • what operating system are you using?

It’s not immediately clear why you’d be getting that error. Thanks!


Thanks for the response.

  • I don’t have a website or URL. I am currently just running Search API in an IDE for research purposes.

  • Version 1.7.0 according to searchtweets.__version__

  • MacOSX El Capitan 10.11.6


Thanks! I meant the endpoint that you’re connecting to - which should be something like:


You would have put that in the yaml file.


Thanks for the clarification.

Endpoint, format taken from twitter docs


I now see

retrying request; current status code: 403
retrying request; current status code: 403
retrying request; current status code: 403
HTTP Error code: 403: Forbidden: Authentication succeeded but account is not authorized to access this resource.
Rule payload: {'query': '#Twitter', 'maxResults': 100}


In your developer dashboard (https://developer.twitter.com/en/dashboard) you should use the application keys that you have set up for the Search API (30-day) dev environment called ‘attempt’


Thank you very much Emily for the prompt clarifications.
This worked for me.

For future inquirers:
I changed the following within my .yaml file



https://api.twitter.com/1.1/tweets/search/30day/[Dev environment label].json

closed #10