Connecting to a Meilisearch service through the internal network
Hi. I have a service (running an Express server) that needs to talk to a Meilisearch server. I haven't been able to have them communicate through the internal network (I tried every possible combination of hostname and port).
It works perfectly when I give my web server the external address of the Meilisearch service, which narrows it down to an internal network issue.
Has anyone dealt with a similar problem? Could it be that the Meilisearch template I use somehow does not expose itself thought IPv6, as this seems to be a requirement?
This is on project ID
3918b55c-337b-41f5-aa1a-752e759a8d01
.
(This question is similar to this other one https://discord.com/channels/713503345364697088/1134873603129741312)
Thanks!Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Solution:Jump to solution
Ohhh, got it:
The correct address was
http://search.railway.internal:3331
, which I had already tried. But to make it work, I had to change the Meilisearch service's MEILI_HTTP_ADDR
, where it listens to requests, to [::]:3331
instead of 0.0.0.0:3331
....14 Replies
Project ID:
3918b55c-337b-41f5-aa1a-752e759a8d01
Long shot, but are you using the correct port?
I've tried the port that's exposed as an environment variable in the Meilisearch service (3331), the local Meilisearch port used in local / dev environments (7700), and plain old 80.
whats your connection string
thanks both for your replies. My connection string is something like
const client = new MeiliSearch({ host: process.env.MEILI_URL, apiKey: process.env.MEILI_MASTER_KEY });
.
It works perfectly well when the MEILI_URL is something like https://my-search-service.up.railway.app
. It fails when it's something like http://search.railway.internal
or http://search.railway.internal:3331
.
I'd be curious if other people have been using the Meilisearch template and how they've configured it. Right now, I have a solution but I'd rather not keep the search server exposed (even if it requires a key to handle requests).so the host variable absolutely does need a port, always use a port going forward
can you share the error message you get when trying to connect
Whenever I try to connect to the internal URL, I get:
This error comes from the Meilisearch JS client, that uses undici to make its http requests.
show me the connection code thingy
Solution
Ohhh, got it:
The correct address was
http://search.railway.internal:3331
, which I had already tried. But to make it work, I had to change the Meilisearch service's MEILI_HTTP_ADDR
, where it listens to requests, to [::]:3331
instead of 0.0.0.0:3331
.so when you deploy the meilisearch template, it has a present variable in the railway ui?
like the template comes with that variable set to 0.0.0.0:3331
yes
can you do me a big favour and check to see if you can still access it externally while the addr is set to ::
Yup, one second
It does work both internally and externally when the address is in the IPv6 style
awesome, thanks! I'll get Ray to change it to [::]:3331