Either use localhost in your code or change network.host setting in your elasticsearch.yml file if you want elasticsearch to be available from other machines.
Read more at https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html