如何从google colab windows机器连接到elasticsearch localhost?

2w2cym1i  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(0)|浏览(663)

我已经运行了用于elasticsearch的localhost,通过python访问
在我的googlecolab中,我安装了‘pip install elasticsearch’,如果我访问es,我会被拒绝

from elasticsearch import Elasticsearch
es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
message_body = {"size":1000, "_source": index_columns, "query":{"match_all":{}}}
elastic_data = es.search(index=data_index, body=message_body, scroll='1m')

低于连接错误

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout,**extra_kw)
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

我试过了

es = Elasticsearch([{'host': 'localhost', 'port': 9200}],timeout=30, max_retries=10, retry_on_timeout=True)

我还是被拒绝了

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题