G
G
great_772020-01-22 23:10:42
symfony
great_77, 2020-01-22 23:10:42

I can't connect to elasticsearch using docker, what could be the reason?

With these options, I can not create a connection to the database: localhost, 0.0.0.0, simpledocker2_elastics

In Http.php line 187:
<i>Couldn't connect to host, Elasticsearch down?</i>

ERROR     [elastica] Elastica Request Failure ["exception" => Elastica\Exception\Connection\HttpException { …},"request" => ["path" => "app","method" => "DELETE","data" => [],"query" => [],"contentType" => "application/json","connection" => ["config" => ["headers" => [],"curl" => []],"host" => "0.0.0.0","port" => 9200,"ssl" => false,"logger" => "fos_elastica.logger","compression" => false,"retryOnConflict" => 0,"enabled" => false]],"retry" => false]

config.yml
fos_elastica:
    clients:
        default: { host: 0.0.0.0, port: 9200}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
great_77, 2020-02-04
@great_77

Add links to php-fpm in docker-compose.yml and connect to:
$hosts = [
'elasticsearch'
];
$client = ClientBuilder::create()->setHosts($hosts)->build();

G
Georg Gaal, 2020-02-02
@gecube

What is the second config? 0.0.0.0 - the host is specified only in the elastic server parameters so that it "listens" to all addresses, and not to any specific one. In the client, you must specify EITHER the IP address of the elastic (host or container), OR the name of the container (service) - if the elastic is running in the
localhost container and 127.0.0.1 for the container, this is, quite logically, the same container. In which NATURALLY elastic is not running. So it's pointless to do so. But there is an exception - when containers are launched without network isolation ( --net host)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question