This content has been automatically translated from Ukrainian.
I had a problem connecting the Elasticsearch service to the Rails application (Coolify in the cloud, server on Hetzner).
I couldn't figure out what format should be used for the ELASTICSEARCH_URL environment variable in Rails. I tried different options - with a password, without a password, via local URL, via external domain - but I constantly received a TCP connection error.
In the end, I figured it out
The correct format for ELASTICSEARCH_URL (added in the Rails container) should be as follows*:
http://login:password@es-container-name:9200
*SSL is a separate conversation
The key point is to use the container name, not the external URL provided in the Coolify Web UI.
The container name can be easily found in the Coolify interface on the General tab.
So if you have something like:
http://<container-name>.server-ip.sslip.io:9200
then to connect within the Docker network, you need to take just the <container-name> part and use it in ELASTICSEARCH_URL (or whatever you are using).
After that, Rails successfully connected to Elasticsearch without any TCP errors.
Perhaps this will save someone time, as the documentation in Coolify is a bit abstract.
This post doesn't have any additions from the author yet.