0

I have a Nginx server with an SSL connection. I also have ElasticSearch installed locally. A basic cURL command and I can ping ElasticSearch. However, my Django application which runs on this Nginx server it can't communicate with ElasticSearch using Ajax.

const QUERY_URL = "http://localhost:9200/topics/_search?q=name:" + QUERY
    + "*&sort=follower_count:desc&size=5";

$.ajax({
    type: 'GET',
    url: QUERY_URL,
    success: function (data) {
        console.log(data);
    },
    error: function (xhr) {
        if (xhr.status === 0) {
            showSnackBarMessage("Can't communicate with server");
        }
    }
});

I always get this error: net::ERR_BLOCKED_BY_CLIENT. I tried changing GET to POST. I also tried enabling cors in the elasticsearch.yml. However, nothing seems to be working. I'm thinking maybe it's because of my SSL connection that's why I'm unable to connect, but i'm not sure.

user2896120
  • 3,180
  • 4
  • 40
  • 100
  • if you try the same request as a curl request do you get an certificate issues? – LhasaDad Aug 18 '20 at 23:46
  • @LhasaDad No, it works fine and returns what I need. If I use Django's elasticsearch_dsl library, it works fine as well (I'm creating a connection with ElasticSearch in the backend) – user2896120 Aug 18 '20 at 23:48
  • any browser extensions installed? adblock, etc might be running into one of them blocking it. – LhasaDad Aug 18 '20 at 23:57
  • @LhasaDad I opened incognito with all extensions disabled, still not working – user2896120 Aug 19 '20 at 00:03
  • @LhasaDad Not working with FireFox either with no extensions enabled – user2896120 Aug 19 '20 at 00:04
  • Ok, no idea at this point, I might suggest bringing up the developer tools console in Chrome and watch the request and see if there are additional messages output. but beyond that at this point I don't have anything else to suggest. – LhasaDad Aug 19 '20 at 00:39
  • Do you think it has anything to do with me making a request with SSL enabled on my server, when ElasticSearch doesn't have an SSL certificate? – user2896120 Aug 19 '20 at 01:18
  • 1
    Does this answer your question? [ElasticSearch not working with same origin](https://stackoverflow.com/questions/63462868/elasticsearch-not-working-with-same-origin) – ibexit Aug 19 '20 at 20:21

0 Answers0