Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 NewConnectonError #27

Open
ajak7 opened this issue Jan 21, 2021 · 2 comments
Open

Python3 NewConnectonError #27

ajak7 opened this issue Jan 21, 2021 · 2 comments

Comments

@ajak7
Copy link

ajak7 commented Jan 21, 2021

Hi.

After a bit of testing I finally managed to get it working... partially.
When running any command I get the " raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10c6a76a0>: Failed to establish a new connection: [Errno 61] Connection refused. " - error.
I think this might occur cause I use python3 instead of python2.

The full output when running the "python3 sentiment.py -s TSLA -k 'Elon Musk',Musk,Tesla,SpaceX --debug" command is :

   _                     _                 
 _| |_ _           _   _| |_ _     _   _   
|   __| |_ ___ ___| |_|   __|_|___| |_| |_ 
|__   |  _| . |  _| '_|__   | | . |   |  _|
|_   _|_| |___|___|_,_|_   _|_|_  |_|_|_|  
  |_|                   |_|   |___|                
      :) = +$   :( = -$    v0.1-b.12
 https://github.com/shirosaidev/stocksight

2021-01-21 07:22:38,527 [INFO][stocksight] Creating new Elasticsearch index or using existing stocksight
2021-01-21 07:22:38,530 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.003s]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 115, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 506, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 200, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x1053adaf0>: Failed to establish a new connection: [Errno 61] Connection refused
2021-01-21 07:22:38,532 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
2021-01-21 07:22:38,533 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.001s]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 115, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 506, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 200, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10539fd90>: Failed to establish a new connection: [Errno 61] Connection refused
2021-01-21 07:22:38,533 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
2021-01-21 07:22:38,534 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.001s]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 115, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 506, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 200, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10539fa90>: Failed to establish a new connection: [Errno 61] Connection refused
2021-01-21 07:22:38,535 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
2021-01-21 07:22:38,536 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.001s]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 115, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 506, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 200, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10539fa30>: Failed to establish a new connection: [Errno 61] Connection refused
2021-01-21 07:22:38,536 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 115, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 506, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 200, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10539fa30>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/casperdavidsen/Downloads/stocksight/sentiment.py", line 862, in
es.indices.create(index=args.index, body=mappings, ignore=[400, 404])
File "/usr/local/lib/python3.9/site-packages/elasticsearch/client/utils.py", line 73, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/local/lib/python3.9/site-packages/elasticsearch/client/indices.py", line 106, in create
return self.transport.perform_request('PUT', _make_path(index),
File "/usr/local/lib/python3.9/site-packages/elasticsearch/transport.py", line 312, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/usr/local/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 124, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x10539fa30>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x10539fa30>: Failed to establish a new connection: [Errno 61] Connection refused)

@Youras
Copy link

Youras commented Jan 28, 2021

you have to run elasticsearch in the background before

@Ritu1969
Copy link

Ritu1969 commented Apr 18, 2022

Hello @Youras What do you mean by "you have to run elasticsearch in the background before". Does it mean, I have to install a separate elasticsearch package and run it independently. If yes then what does "docker exec -it stocksight_stocksight_1 bash" do as in README file as I have all three containers running.
docker-desktop
What should I do next?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants