NoNodeAvailableException error

I am trying to save data in elasticsearch database through REST API using SpringBoot.I am using the following in my application.yml file

  data:
    elasticsearch:
      username: xxxxx
      password: xxxxx
      host: xxxxx
      node-name: xxxxx
      cluster-name: xxxx
      cluster-nodes: localhost:9300
      client:
        transport:
          ignore_cluster_name: true

I am keeping the Config File blank

On running the project I am getting the following logs

main org.elasticsearch.client.transport.TransportClientNodesService - {} - node {#transport#-1}{m-Y19jlaSfOhQNkqjzzDaw}{localhost}{127.0.0.1:9300} not part of the cluster Cluster [xxxxxx], ignoring...
[2020-04-20 18:42:14,881] ERROR failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{m-Y19jlaSfOhQNkqjzzDaw}{localhost}{127.0.0.1:9300}] (org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository:91)
[INFO] 2020-04-20 18:42:15,476 main org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - {} - Initializing ExecutorService 'applicationTaskExecutor'
Apr 20, 2020 6:42:16 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
[INFO] 2020-04-20 18:42:16,094 main org.springframework.boot.web.embedded.tomcat.TomcatWebServer - {} - Tomcat started on port(s): 8080 (http) with context path ''
[INFO] 2020-04-20 18:42:16,098 main com.target.ejtricklearchiverks.Main - {} - Started Main in 5.014 seconds (JVM running for 5.708)
[WARN] 2020-04-20 18:42:19,475 elasticsearch[_client_][generic][T#2] org.elasticsearch.client.transport.TransportClientNodesService - {} - node {#transport#-1}{m-Y19jlaSfOhQNkqjzzDaw}{localhost}{127.0.0.1:9300} not part of the cluster Cluster [xxxxxxx], ignoring...
[WARN] 2020-04-20 18:42:24,496 elasticsearch[_client_][generic][T#1] org.elasticsearch.client.transport.TransportClientNodesService - {} - node {#transport#-1}{m-Y19jlaSfOhQNkqjzzDaw}{localhost}{127.0.0.1:9300} not part of the cluster Cluster [xxxxxxx], ignoring...

Can anyone please help with this error

Few comments:

Sure. But you are using the deprecated TransportClient here which is not using the REST Layer (9200) but the Transport Layer (9300).

You should switch to the rest client instead. I guess you are using spring data elasticsearch, so have a look at their documentation on how to switch to the REST Client.

Can you please provide the link to the documentation

A simple google search drove me to https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.rest

I will not be able to use REST Client as some part of the code fetches data through kafka which would make it very slow. Is there any other alterenartive ?

Why do you think so?

I am able to save the data on elasticsearch version locally which runs on localhost:9200 but not on the database on my companies server. My code is what it was at the beginning and I am getting the error while only while using the database in my companie's server.

Is it because it may have a different transport client instead of localhost:9300 ?

That's not the same question. Why do you think it will be slow which prevents you using the REST Client?