akhtarvahid
akhtarvahid

Reputation: 9779

Error while creating post in nestjs with Elastic search

I have a Nestjs application that runs locally perfectly along with elastic search and Postgres. I am trying to create post which is working without elastic search but with elastic search i get error saying

[Nest] 197  - 09/20/2024, 5:53:12 PM   ERROR [ExceptionsHandler] connect ECONNREFUSED ::1:9200
nestjs_api-1   | ConnectionError: connect ECONNREFUSED ::1:9200

whereas my http://localhost:9200/ is working

// 20240920231715
// http://localhost:9200/

{
  "name": "f3b67858bef0",
  "cluster_name": "docker-cluster",
  "cluster_uuid": "5UDcdBG8Qgu7l-CTdBz46w",
  "version": {
    "number": "8.10.0",
    "build_flavor": "default",
    "build_type": "docker",
    "build_hash": "e338da74c79465dfdc204971e600342b0aa87b6b",
    "build_date": "2023-09-07T08:16:21.960703010Z",
    "build_snapshot": false,
    "lucene_version": "9.7.0",
    "minimum_wire_compatibility_version": "7.17.0",
    "minimum_index_compatibility_version": "7.0.0"
  },
  "tagline": "You Know, for Search"
}

Elastic search method

this.elasticsearchService.index({
      index: this.index,
      id: 'task - ' + task.id,
      body: {
        id: task.id,
        title: task.title,
        description: task.description,
        status: task.status
      }
    })

Need help to resolve or guidance what mistake I'm making

Upvotes: 0

Views: 22

Answers (1)

Mathew
Mathew

Reputation: 592

::1:9200 is 127.0.0.1:9200.

127.0.0.1 and localhost are not exactly the same. 127.0.0.1 is restricted by firewalls and network cards.

You need to check your network or change the access address to localhost directly.

Upvotes: 0

Related Questions