Unable to access Browserless service through private network
Hi, I have a Node.js API running in a service and a Browserless instance in another service. Both are in the same project and both are deployed from Docker images. I can't seem to get the private networking to work. Every time my API tries to connect to Browserless through the internal link, it errors out
Error: getaddrinfo ENOTFOUND browserless.railway.internal
. When using the public address for Browserless, it works fine. Any ideas what could be the issue?
Thanks
Project ID: 1cd9e13b-7e15-421e-9db9-c908c4e42e7e20 Replies
Project ID:
1cd9e13b-7e15-421e-9db9-c908c4e42e7e
Project ID:
1cd9e13b-7e15-421e-9db9-c908c4e42e7e
Private Networking takes 100ms to initialize, you'd need to add a bit of initial delay before trying to connect to the private network
3 seconds is a good amount
I believe that puppeteer (the library I'm using to connect to Browserless) has a 30second timeout by default, so that should be plenty. Can you think about anything else that could be the issue here?
Timeout != Delay
Could u try adding the
sleep 3 && ~your start command~
?Oh, so do you mean delay after the browserless service starts up? Sorry I meant that on every connection it needs the extra 100ms. I will try your solution, but I don't think this should be the issue then, because the service has been up for nearly an hour now. (Sorry if I'm not understanding something here)
Try it, we'll see.
Its a common issue with railway's private networking
delay before the browserless service starts
another question that might be worth asking, are you deploying your node api with nixpacks?
No, I'm not. I am using just my own Dockerfile to build the image. Tbh this is the first time I'm hearing about nixpacks.
does the dockerfile use an alpine image?
yes
give this docs section a read please https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images
🤦♂️🤦♂️ I actually read it, I just didn't think about it as I was so focused on the issue being somewhere in the Browserless deployment ... Thanks, I'll try adding the env var!
Interestingly enough, adding the env variable to Railway, crashed my startup command. I am using https://infisical.com/ to manage my env variables and that injects variables with the startup command like so
infisical run -- node server.js
. The error being "dial tcp: lookup app.infisical.com on [fd12::10]:53: dial udp [fd12::10]:53: connect: cannot assign requested address"you still need the delay like medium said
So I added the sleep, which fixed the issue with the startup of the node app, however the error with the connection still remains. One thing though, I added the sleep only to the node container as I'm not too sure what startup command to use with the browserless container.
the browserless container does not need a started delay
what error are you seeing now
Basically the same error as in the beginning
Error: connect ECONNREFUSED fd12:8e79:a9ab::3f:26ae:72f2:443
but what's changed is that the domain name has been switched for IPv6 addrokay perfect your app can now do a DNS lookup, what I think is happening is that the browserless service is not listening on an IPv6 address, it needs to because the private network is IPv6 only, I'll look into this, but no promises on a resolution
Thanks for the help with this, I have been using the public URL so far but I recognise it’s a very bad and potentially expensive idea since basically anyone could use my browserless instance 😳 Am I right in thinking that there is no dedicated firewall/NAT gateway setup on Raliway?
you are correct, instead you want to remove the public domain and only use the internal private domain