Gitlab CI connection refused on elasticsearch

I try to connect elasticsearch on Gitlab CI for running my test but always got connection refused

here my script

      - name:          
        command: [ "bin/elasticsearch", "", "-Ediscovery.type=single-node" ]
      - curl "http://$(cat /etc/hosts |grep $HOSTNAME|cut -d$'t' -f1):9200"

Wtih $(cat /etc/hosts |grep $HOSTNAME|cut -d$'t' -f1) I can get IP address

I try to use alias: elasticsearch but when I curl "http://elasticsearch:9200" also got error Could not resolve host

Source: StackOverflow