解决Kibana——Unable to connect to Elasticsearch at http....9200

解决Kibana—Unable to connect to Elasticsearch at http:…:9200.

If you have a hint, can you know the reason is that you can’t connect to elasticsearch. First of all, the reason for locating the error is the problem of the ip address.

Insert picture description here

According to the information on the Internet and my own practice, three solutions are summarized (when the es and kibanan versions are the same)

method one:

Change the ip of ElasticSearch to 127.0.0.1orlocalhost

docker run -it -d -e ELASTICSEARCH_URL=http://127.0.0.1:9200 --name kibana_es -p 5602:5601 kibana:5.6.8

Method Two:

Set ip to be consistent with the value of network.host in the ElasticSearch configuration file:

  • Enter the ElasticSearch container

    docker exec -it es /bin/bash
    
  • View configuration file

    cd config/
    
  • Edit configuration file

    vim elasticsearch.yml
    
  • Add the following configuration information

    http.cors.enabled: true
    http.cors.allow-origin: "*"
    network.host: 192.168.181.5 #具体的ip要根据自己的情况来定,此处是本人虚拟机的ip
    
  • Create Kibana container

  docker run -it -d -e ELASTICSEARCH_URL=http://192.168.181.5:9200 --name kibana_es -p 5602:5601 kibana:5.6.8

Method three:

Ultimate method

  • Enter the ES container

    dockerexec -it es /bin/bash
    
  • View ip (ip of docker internal LAN)

    cat /etc/hosts
    

    We will see the following:
    Insert picture description here

    We can know that the ip of the es container in docker is172.17.0.3

  • Next, you can create a container based on this ip

    docker run -it -d -e ELASTICSEARCH_URL=http://172.17.0.3:9200 --name kibana -p 5601:5601 kibana:5.6.8
    

Successful screenshot:
Insert picture description here

Hope the above methods can help you solve the problem

Guess you like

Origin blog.csdn.net/weixin_44829930/article/details/108794959