python客户端无法远程连接到elasticsear

时间:2016-02-07 20:27:37

标签: python python-2.7 elasticsearch

此代码在我的机器上完美运行,该机器具有与服务器完全相同的弹性版本,

from elasticsearch import Elasticsearch
        es = Elasticsearch(['the server ip is here'], port=9200) 

        body = json.dumps(itemDictionary, ensure_ascii=True)
        es.index(index = 'indexname', doc_type = 'doc', body = body)

我收到此错误

WARNING:elasticsearch:POST http://the ip of the server:9200/indexname/doc [status:N/A request:0.197s]

es.index(index = 'indexname', doc_type = 'doc', body = body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 261, in index
    _make_path(index, doc_type, id), params=params, body=body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/elasticsearch/transport.py", line 307, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 89, in perform_request
    raise ConnectionError('N/A', str(e), e)
ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x10cc62550>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x10cc62550>: Failed to establish a new connection: [Errno 61] Connection refused)

python版本为2.7,弹性版本为2.1.1

0 个答案:

没有答案