Elasticpress: There is a problem with connecting to your Elasticsearch host.

Created on 24 Apr 2018  路  13Comments  路  Source: 10up/ElasticPress

Have you searched for similar issues before submitting this one?
I have

Is this a bug, question or feature request?
bug

Describe the issue you encountered:
Error message from setup page:

"There is a problem with connecting to your Elasticsearch host."

Current WordPress version:
4.9.5

Current ElasticPress version:
2.5

Current Elasticsearch version:
6.1.0

Where do you host your Elasticsearch server:
localhost:9200

Other plugins installed (WooCommerce, Simple Redirect Manager, etc..):
+----------------------------------------+----------+-----------+---------+
| name | status | update | version |
+----------------------------------------+----------+-----------+---------+
| akismet | active | available | 3.3.3 |
| autoptimize | inactive | available | 2.2.2 |
| backwpup | active | none | 3.4.5 |
| better-wordpress-syntax-based-on-geshi | active | none | 1.0.6 |
| crayon-syntax-highlighter | active | none | 2.8.4 |
| duplicator | inactive | available | 0.5.12 |
| easy-wp-smtp | active | available | 1.2.5 |
| elasticpress | active | none | 2.5 |
| wp-email-login | active | none | 4.6.4 |
| fancy-gallery | active | available | 1.6.23 |
| login-with-ajax | active | none | 3.1.7 |
| p3-profiler | inactive | none | 1.5.3.9 |
| q-and-a-plus | active | none | 1.1.1 |
| rounded-tag-cloud | active | none | 1.0 |
| search-and-replace | active | none | 3.1.2 |
| simple-image-widget | active | available | 4.4.1 |
| social-bartender | active | none | 1.2.0 |
| ssh-sftp-updater-support | active | available | 0.7.1 |
| user-switching | active | none | 1.3.0 |
| wordpress-importer | inactive | available | 0.6.1 |
| wp-optimize | active | available | 2.1.1 |
| wp-recaptcha | active | none | 4.1 |
| wp-better-emails | active | none | 0.3 |
| wp-symposium-pro | active | available | 17.06 |
| wp-symposium-pro-extensions | active | none | 17.06 |
+----------------------------------------+----------+-----------+---------+

Steps to reproduce:

  1. Install plugin
  2. define('EP_HOST', 'http://127.0.0.1:9200' ); in wp-config.php
  3. Experience error message in setup window.

Note:

"wp elasticpress status" returns succesfully
curl -X GET "localhost:9200/" returns succsfully

I can put and get resources manually using curl.

Screenshots, if needed:

question

Most helpful comment

I started having the same issue after upgrading to Ubuntu 18.04. I was able to CURL but could not connect through ElasticPress.

I did run debug bar and it was showing no issues even though I wasn't connecting. I did try without any other plugins activated and was still not getting a connection through ElasticPress.

For my setup I was able to connect to the Elasticsearch server through the plugin with the following in my functions.php:

add_filter( 'ep_format_request_headers', function ( $headers ) {
    $headers['Accept-Encoding'] = 'gzip';
    return $headers;
});

All 13 comments

Try to leave out the changes in wp-config.php as you use the default settings anyway. You should not use http:// before any ip.

Thanks, the install notes state:

Input your Elasticsearch host. Your host must begin with a protocol specifier (http or https). URLs without a protocol prefix will not be parsed correctly and will cause ElasticPress to error out.

Just inputting the ip adress/port also fails.

Right, sorry about that. Please try to comment out that line in wp-config.php - it will work without as you run a default localhost server.

I have commented the line, still the same behaviour.

Does wp-debug gives anything?

It does not.

I tracked this down to an issue with the responses from elastic search being compressed (deflate), I modified the headers in class-ep-api.php

$headers["Accept-Encoding"] = "*";

Now this was just a test, I'm keen to discover what the proper fix for this is.

That's strange, try it once with other plugins disabled, it can be a plugin conflict. Can you put what response you are seeing in Debug Bar ElasticPress: https://wordpress.org/plugins/debug-bar-elasticpress/ plugin?

@realisable Have you had a chance to run the ElasticPress Debug Bar?

@realisable any update?

Hi this project is on hold, I'll run the debug once it's picked up again.

I started having the same issue after upgrading to Ubuntu 18.04. I was able to CURL but could not connect through ElasticPress.

I did run debug bar and it was showing no issues even though I wasn't connecting. I did try without any other plugins activated and was still not getting a connection through ElasticPress.

For my setup I was able to connect to the Elasticsearch server through the plugin with the following in my functions.php:

add_filter( 'ep_format_request_headers', function ( $headers ) {
    $headers['Accept-Encoding'] = 'gzip';
    return $headers;
});

@rossluebe I had this issue today, thank you for posting that solution!

Thank you, @rossluebe - that add_filter() fix in wp-includes/functions.php solved the problem on my site as well!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keg picture keg  路  4Comments

mihaijoldis picture mihaijoldis  路  6Comments

barryceelen picture barryceelen  路  4Comments

psorensen picture psorensen  路  7Comments

JJJ picture JJJ  路  5Comments