0

I have been following a simple tutorial about developing a personalized voice assistant. For that, I am using Elasticsearch. when I try to run the code, I get an error from elasticsearch saying Failed to establish new connection. I am not sure what is causing this error as I have installed both elasticsearch as well as its python client.

I have checked whether I have installed both elastic search and its python client and i have done it. I have installed python client through pip3 installation. I have also checked whether the connection URL and i believe it is correct i.e. https://localhost:9200/.

I am using macOS.

s = Elasticsearch(['https://localhost:9200/']) bulk(es, records, index='voice_assistant', doc_type='text', raise_on_error=True) def search_es(query): res = es.search(index="voice_assistant", doc_type="text", body={ "query" :{ "match": { "voice_command": { "query": query, "fuzziness": 2 } } }, }) return res['hits']['hits'][0]['_source']['sys_command' 

The actual error message is

File "/usr/local/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 105, in perform_request raise ConnectionError('N/A', str(e), e) elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused) 

Can anyone please help me fix this error. I am using elasticsearch for the first time.

EDIT: I have tried to run elasticsearch in terminal and I have got this following warning,

OpenJDK 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory 

I have googled further about this waring and found an answer mentioning it probably might be ab ug in elastic search which I am not sure as I am using the latest version. The answer I was mentioning is

https://stackoverflow.com/questions/48696080/java-hotspottm-64-bit-server-vm-warning-cannot-open-file-logs-gc-log-due-to-no 

Edit2: Now when i try to launch elasticsearch in erminal i get the following error

StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/var/lib/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])? at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.4.0.jar:7.4.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.4.0.jar:7.4.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.4.0.jar:7.4.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.4.0.jar:7.4.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.4.0.jar:7.4.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.4.0.jar:7.4.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.4.0.jar:7.4.0] 

I got the same error yesterday as well but when I restarted my system, it all works fine, is it because that some kind of operation is running behind and does it have any specific killall command to terminate all the operations before starting it?

9
  • try to connect with http protocol and not https in the url. Commented Oct 3, 2019 at 10:55
  • I did, it was the same error. Isn't this error linked to the error I have received while trying to run Elasticsearch in terminal, it says Error opening log file 'logs/gc.log': No such file or directory Commented Oct 3, 2019 at 11:05
  • first of all first check if your elasticsearch is up and running by cheking its service status and type the same url in your browser and check if you are connected to your ES or not. Commented Oct 3, 2019 at 11:45
  • yes elasaticsearch is up and running, i have fixed the error regarding log file and now when i usee http protocol i get following error raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info) elasticsearch.exceptions.TransportError: <exception str() failed> Commented Oct 3, 2019 at 13:23
  • would request you to link your complete error log here, and what you are trying to do. Commented Oct 4, 2019 at 4:49

1 Answer 1

1

well by using the latest version of python-es module the issue got resolved so its better to upgrade the module. In the above case the previous version being used was 2.4.0v and the latest version now being used is 6.0.0v, hence the problem got resolved.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.