Trying to send logs

i have installed ELK stack using docker where it has ip-172.x.x.x. which is running on ubuntu machine (with ip now i am trying to send logs of my 2nd ubuntu machine( to ELK (

so, i have configured filebeat in my 2nd ubuntu machine( and configured the output to send elasticsearch (
but when i see filebeat logs it says refused connection. so , couldn’t send logs.

also when i tried curl in elk machine " connection is refused"
but when i try with chrl http://172.x.x.x:9200 in elk machine it works and gives output

-can any one help me. how should i make it accept the logs.