Unable to connect to Elasticsearch with PHP inside Docker Unable to connect to Elasticsearch with PHP inside Docker elasticsearch elasticsearch

Unable to connect to Elasticsearch with PHP inside Docker


You tried to connect to localhost, but you need to connect to "elastic" host.try to connect to elasticsearch from php like this:

$hosts = [    'elastic', // elastic host was added to you hosts file automatically];$client = ClientBuilder::create()   ->setHosts($hosts)   ->build();

Containers for the linked service will be reachable at a hostname identical to the alias, or the service name if no alias was specified.