Failed to connect to localhost port 9200: Connection refused

From a fresh install of Ubuntu 16.04:

sudo apt-get install elasticsearch

After that, the following should work but doesn't:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sleep 10
curl http://localhost:9200/

Despite that, the following does work:

sudo -u elasticsearch /usr/share/elasticsearch/bin/elasticsearch &
sleep 10
curl http://localhost:9200/

Comments