R
Railway16mo ago
louije

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:
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....
Jump to solution
14 Replies
Percy
Percy16mo ago
Project ID: 3918b55c-337b-41f5-aa1a-752e759a8d01
ThallesComH
ThallesComH16mo ago
Long shot, but are you using the correct port?
louije
louijeOP16mo ago
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.
Brody
Brody16mo ago
whats your connection string
louije
louijeOP16mo ago
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).
Brody
Brody16mo ago
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
louije
louijeOP16mo ago
Whenever I try to connect to the internal URL, I get:
MeiliSearchCommunicationError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errno: undefined,
code: undefined
}
MeiliSearchCommunicationError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errno: undefined,
code: undefined
}
This error comes from the Meilisearch JS client, that uses undici to make its http requests.
Brody
Brody16mo ago
show me the connection code thingy
Solution
louije
louije16mo ago
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.
Brody
Brody16mo ago
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
louije
louijeOP16mo ago
yes
Brody
Brody16mo ago
can you do me a big favour and check to see if you can still access it externally while the addr is set to ::
louije
louijeOP16mo ago
Yup, one second It does work both internally and externally when the address is in the IPv6 style
Brody
Brody16mo ago
awesome, thanks! I'll get Ray to change it to [::]:3331
Want results from more Discord servers?
Add your server