Editing /etc/hosts file with domain name?

Hi,

I was trying to figure out why I couldn’t get some command line curl requests to work. Turns out /etc/hosts has:

127.0.0.1 admin.mydomain.com

I thought maybe my scripts were installing that , but it seems to be coming from hst-install-ubuntu.sh:

if [[ -z $(grep -i "$servername" /etc/hosts) ]]; then
    echo "127.0.0.1 $servername" >> /etc/hosts
fi

Is there a reason for that? If I comment it out, it works fine:

curl -4 http://admin.mydomain.com:8338/fail2ban
179.43.177.154
152.89.196.123
173.214.175.178
193.169.255.19

But with that line in the /etc/hosts, I get:


curl -4 http://admin.mydomain.com:8338/fail2ban
curl: (7) Failed to connect to admin.mydomain.com port 8338: Connection refused

I’ve commented it out for now so that it works, but I just want to try and understand why its in there, and if its important I leave it?

Thanks

Andy