microblog
microblog copied to clipboard
Elasticsearch connection error
Hello, I am getting this error when I try to search. Kindly assist.
Traceback (most recent call last): File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/connection.py", line 169, in _new_conn conn = connection.create_connection( File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection raise err File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/elasticsearch/connection/http_urllib3.py", line 249, in perform_request response = self.pool.urlopen( File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen retries = retries.increment( File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/util/retry.py", line 506, in increment raise six.reraise(type(error), error, _stacktrace) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise raise value File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 394, in _make_request conn.request(method, url, **httplib_request_kw) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/connection.py", line 234, in request super(HTTPConnection, self).request(method, url, body=body, headers=headers) File "/usr/lib/python3.8/http/client.py", line 1255, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.8/http/client.py", line 1301, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.8/http/client.py", line 1250, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.8/http/client.py", line 1010, in _send_output self.send(msg) File "/usr/lib/python3.8/http/client.py", line 950, in send self.connect() File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/connection.py", line 200, in connect conn = self._new_conn() File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/urllib3/connection.py", line 181, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f749a2f1520>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 2464, in call return self.wsgi_app(environ, start_response) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app response = self.handle_exception(e) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception reraise(exc_type, exc_value, tb) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view return func(*args, **kwargs) File "/home/samuel/Desktop/biblechats/app/main/routes.py", line 152, in search posts, total = Post.search(g.search_form.q.data, page, File "/home/samuel/Desktop/biblechats/app/models.py", line 15, in search ids, total = query_index(cls.tablename, expression, page, per_page) File "/home/samuel/Desktop/biblechats/app/search.py", line 22, in query_index search = current_app.elasticsearch.search( File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/elasticsearch/client/utils.py", line 152, in _wrapped return func(*args, params=params, headers=headers, **kwargs) File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/elasticsearch/client/init.py", line 1657, in search return self.transport.perform_request( File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/elasticsearch/transport.py", line 413, in perform_request raise e File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/elasticsearch/transport.py", line 381, in perform_request status, headers_response, data = connection.perform_request( File "/home/samuel/Desktop/biblechats/venv/lib/python3.8/site-packages/elasticsearch/connection/http_urllib3.py", line 262, in perform_request raise ConnectionError("N/A", str(e), e) elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f749a2f1520>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f749a2f1520>: Failed to establish a new connection: [Errno 111] Connection refused)
Are you running the Elasticsearch service?
Not sure, i just added elasticsearch environment variable in the .env file. How to i start the service?
@SamwayneKE you have to install it and start it. Are you reading the tutorial?
Not sure, i just added elasticsearch environment variable in the .env file. How to i start the service?
you can try this tutorial on how to install elasticsearch on your machine https://www.youtube.com/watch?v=BybAetckH88&t=389s and also when connecting to your elasticsearch server don't forget to send the user password otherwise it won't work