Dear All
I solved the issue.
I used the docker image to run the elastic search.
The command on this page: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.4.3
-e "transport.host=127.0.0.1" did not work.
I have to change the elasticsearch.yml, uncomment this line:
transport.host: 0.0.0.0
So that the transport client can correctly connect to port 9300.