Elasticsearch에서 연결 거부 오류
Elasticsearch를 사용하여 연결을 시도했을 때 curl http://localhost:9200
제대로 작동합니다.
그러나 내가 실행하면 curl http://IpAddress:9200
오류가 발생 connection refused port 9200
합니다.
이 오류를 해결하는 방법은 무엇입니까?
기본적으로 모든 로컬 주소에 바인딩되어야합니다. 그래서, 당신을 가정하는 것은 단지 내가 검사로 생각할 수있는 설정 ES, 방화벽과 네트워크 계층의 문제를 가지고 있지 않습니다 network.bind_host
그것은 하나 설정되어 있지 않거나으로 설정되어 있는지 확인 0.0.0.0
하거나 ::0
또는 네트워크에 대한 올바른 IP 주소로.
업데이트 : ES 2.3의 주석에 따라 network.host
대신 설정해야 합니다.
/etc/elasticsearch/elasticsearch.yml
다음 행을 편집 하고 추가하십시오.
network.host : 0.0.0.0
이것은이 매개 변수를 "설정 해제"하고 다른 IP로부터의 연결을 허용합니다.
이 페이지의 모든 것을 시도했으며 여기의 지침 만 도움이되었습니다.
에서 /etc/default/elasticsearch
주석이 없는지 확인하십시오.
START_DAEMON=true
ES_USER=elasticsearch
ES_GROUP=elasticsearch
LOG_DIR=/var/log/elasticsearch
DATA_DIR=/var/lib/elasticsearch
WORK_DIR=/tmp/elasticsearch
CONF_DIR=/etc/elasticsearch
CONF_FILE=/etc/elasticsearch/elasticsearch.yml
RESTART_ON_UPGRADE=true
/var/lib/elasticsearch
elasticsearch 사용자가 소유하고 있는지 확인하십시오 .
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch/
제 경우에는 elasticsearch가 시작되었습니다. 하지만 여전히
curl: (7) Failed to connect to localhost port 9200: Connection refused
다음 명령이 실패했습니다.
sudo service elasticsearch restart
작동하려면 대신 실행해야했습니다.
sudo systemctl restart elasticsearch
그런 다음 모든 것이 잘되었습니다.
이 명령 줄로 시작하는 것이 어떻습니까?
$ sudo service elasticsearch status
나는 그것을했고 얻는다 :
"There is insufficient memory for the Java Runtime..."
그런 다음 /etc/elasticsearch/jvm.options
파일을 편집했습니다 .
...
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
#-Xms2g
#-Xms2g
-Xms512m
-Xmx512m
################################################################
...
이것은 매력처럼 작동했습니다.
여기에서 제안 된 솔루션 중 어느 것도 나를 위해 일하지 않았지만 결국 작동하게 된 것은 다음을 추가하는 것입니다. elasticsearch.yml
network:
host: 0.0.0.0
http:
port: 9200
After that, I restarted the service and now I can curl
it from both within the VM and externally. For some odd reason, I had to try a few different variants of a curl
call inside the VM before it worked:
curl localhost:9200
curl http://localhost:9200
curl 127.0.0.1:9200
Note: I'm using Elasticsearch 5.5 on Ubuntu 14.04
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
be sure that the server is started. I've seen this problem when my virtual machine had too litle RAM and es could not start.
sudo systemctl status elasticsearch
the above will show you if es is indeed running.
For this problem, I had to use : sudo /usr/share/elasticsearch/bin/elasticsearch start
to be able to get something on ports 9200/9300 (sudo netstat -ntlp) and a response to:
curl -XGET http://localhost:9200
Open your Dockerfile under elasticsearch folder and update "network.host=0.0.0.0" with "network.host=127.0.0.1". Then restart the container. Check your connection with curl.
$ curl http://docker-machine-ip:9200
{
"name" : "vI6Zq_D",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "hhyB_Wa4QwSX6zZd1F894Q",
"version" : {
"number" : "5.2.0",
"build_hash" : "24e05b9",
"build_date" : "2017-01-24T19:52:35.800Z",
"build_snapshot" : false,
"lucene_version" : "6.4.0"
},
"tagline" : "You Know, for Search"
}
I had the same problem refusing connections on 9200 port. Check elasticsearch service status with the command sudo service elasticsearch status
. If it is presenting an error and you read anything related to Java, probably the problem is your jvm memory. You can edit it in /etc/elasticsearch/jvm.options
. For a 1GB RAM memory machine on Amazon environment, I kept my configuration on:
-Xms128m
-Xmx128m
After setting that and restarting elasticsearch service, it worked like a charm. Nmap and UFW (if you use local firewall) checking should also be useful.
Edit elasticsearch.yml
and add the following line
http.host: 0.0.0.0
network.host: 0.0.0.0
didn't work for
In this case, first of all you need to check the java version using below command:
java -version
after running this command you get something like this:
java version "1.7.0_51" OpenJDK Runtime Environment (rhel-2.4.5.5.el7-x86_64 u51-b31) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
then use this command:
update-alternatives --config java
and select the below version
*+ 1 /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64/jre/bin/java 2 /usr/java/jdk1.8.0_73/jre/bin/java
Enter to keep the current selection[+], or type selection number: 2
curl -XGET http://127.0.0.1:9200
My 2 cents,
I just followed the install procedure on Digital Ocean, apparently the package available in the repos is not up to date, I deleted everything and followed the install procedure direct from Elastic Search and everything is working now, basically the out of the box behaviour is on a localhost pointing to 9200. Same thing/issue found with Kibana, the solution for me was too, to remove everything and just follow their procedure, Hope this saves someone two hours (the time I spent figuring out how to setup ELK!)
en
Change the network.bind to 0.0.0.0 and http:port to 9200. The bind address 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.
If you encounter the Connection refused error, simply run the command below to check the status of ElasticSearch service
sudo service elasticsearch status
This will help you decipher the state of ElasticSearch service and what to do about it.
I experienced a similar issue.
Here's how I solved it
Run the service command below to start ElasticSearch
sudo service elasticsearch start
OR
sudo systemctl start elasticsearch
If you still get the error
curl: (7) Failed to connect to localhost port 9200: Connection refused
Run the service command below to check the status of ElasticSearch
sudo service elasticsearch status
OR
sudo systemctl status elasticsearch
If you get a response (Active: active (running)) like the one below then you ElasticSearch is active and running
● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: enabled) Active: active (running) since Sat 2019-09-21 11:22:21 WAT; 3s ago
You can then test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost using the command below:
curl http://localhost:9200
Else, if you get a response a different response, you may have to debug further to fix it, but the running the command below, will help you detect what caveats are holding ElasticSearch service from starting.
sudo service elasticsearch status
OR
sudo systemctl status elasticsearch
If you want to stop the ElasticSearch service, simply run the service command below;
sudo service elasticsearch stop
OR
sudo systemctl stop elasticsearch
N/B: You may have to run the command sudo service elasticsearch status
OR sudo systemctl status elasticsearch
each time you encounter the error, in order to tell the state of the ElasticSearch service.
This also applies for Kibana, run the command sudo service kibana status
OR sudo systemctl status kibana
each time you encounter the error, in order to tell the state of the Kibana service.
That's all.
I hope this helps.
After utilizing some of the answers above, don't forget that after an apt install, a total reboot might be in order.
Just to add on this, I've came across many docs through google that said to set network.host to localhost.
Doing so gave me the infamous connection refused. You must use an IP address (127.0.0.1), not a FQDN.
Jeff
Update your jdk to latest minimum version for your elasticsearch.
Make sure that port 9200
is open for my case it was an amazon instance so when i opened it in my security group the curl command worked.
Disabling SELinux worked for me, although I don't suggest it - I did that just for a PoC
My problem was I could not work with localhost
I needed to set it to localhost's IP address
network.bind_host: 127.0.0.1
참고URL : https://stackoverflow.com/questions/31677563/connection-refused-error-on-elasticsearch
'Programing' 카테고리의 다른 글
Stateless 및 Stateful Enterprise Java Bean (0) | 2020.09.08 |
---|---|
ipython 노트북 출력 창 크기 조정 (0) | 2020.09.08 |
DataContext 속성을 사용하여 XAML의 창에서 ViewModel을 설정하려면 어떻게해야합니까? (0) | 2020.09.08 |
문자열을 변수 이름으로 변환 (0) | 2020.09.08 |
파이썬에서 변수 인수 (kwargs)에서 클래스 속성을 설정하는 방법 (0) | 2020.09.08 |