Unable to connect to Bun service via private URL

plumillonHOBBY

3 months ago

Hi Railway,

I'm unable to make my service (call it webApp) communicate with another (Bun) via the private network.

Public domain works fine but not the private domain.
I'm surely doing something wrong but I cannot pinpoint it.

Here is my Bun (let's call it theBun):
Bun.serve({

hostname: "::",

port: import.meta.env.PORT ?? 3000,

async fetch(request) {

// Doing stuff

},

});

I tried setting the URL like that:
- http://${{theBun.RAILWAY_PRIVATE_DOMAIN}}
- http://${{theBun.RAILWAY_PRIVATE_DOMAIN}}:${{theBun.PORT}}

EDIT:
More context and testing:
I'm able to connect to my webApp to another service (named strapi) via private domain:port.
But I can't do the same from another Bun service (same URL) and I got a connection refused error.

So I guess it's the Bun services which are not properly configured.

What I'm missing?
Thx for your answers.

Solved

6 Replies

3 months ago

Does the server successfully listen when starting?


Status changed to Awaiting User Response railway[bot] 3 months ago


angelo

Does the server successfully listen when starting?

plumillonHOBBY

3 months ago

Hi anglelo,

Yes it does, no error and everything works fine while using the public domain.


Status changed to Awaiting Railway Response railway[bot] 3 months ago


plumillon

Hi anglelo,Yes it does, no error and everything works fine while using the public domain.

plumillonHOBBY

3 months ago

Oki, after investigating I realised something silly: I'm building my Flutter app for web so everything is executed over http via js.
Which mean my requests are going over public network and don't seem to be able to see the private network.
Can you confirm it's normal behaviour?

Now I'm investigating the private network communication between the other Buns. Can we let this thread open?
If you have insights it would help.

EDIT: I just tested and my Bun is unable to access my Strapi instance via private network (http://${{strapi.RAILWAY_PRIVATE_DOMAIN}}:${{strapi.PORT}}).

I got this error:
error: Unable to connect. Is the computer able to access the url?

Mar 14 10:38:59

path: "http://outerly-staging-strapi.railway.internal:1337/api/..........";,

Mar 14 10:38:59

errno: 0,

Mar 14 10:38:59

code: "ConnectionRefused",

On this code:

                        const response = await fetch(
                            new Request(process.env.API_URL!, {
                                method: "PUT",
                                body: JSON.stringify({ userId, type, status: status }),
                                headers: {
                                    "Authorization": `Bearer ${process.env.API_SECRET!}`,
                                    "Content-Type": "application/json"
                                }
                            })
                        );

plumillonHOBBY

3 months ago

I'm back, I found the issue: Strapi cannot doesn't seem to be able to listen to ipv6 (yet).
Would you think it would be possible to Dockerize my Strapi and route the ipv6 request to the container ipv4?


3 months ago

That sounds doable ! I know some people have successfully added a proxy to non ipv4 services to add ipv6 compatibility - however I'm not familiar with the subject myself


Status changed to Awaiting User Response railway[bot] 3 months ago


plumillonHOBBY

3 months ago

I looked into it, it's definitively doable and I'll do it later.
Thanks for the support and being the perfect duck, you can resolve the thread if you like :)


Status changed to Awaiting Railway Response railway[bot] 3 months ago


Status changed to Solved itsrems 3 months ago