2 years ago
I'm getting an error connecting to a database instance from a different service. This has worked pretty much flawlessly for two years, but now I'm getting this error when the deployment migration is performed from a Dockerfile:
Error: P1001: Can't reach database server at monorail.proxy.rlwy.net:10861
The existing service, still running, can connect fine. And I can connect to the database remotely as well.
project: 58cd7410-04d6-4c6e-a74d-fa7c78455231
service: a6f97426-e4a4-4286-a7cf-c259f98f5ff9
174 Replies
2 years ago
to be clear, you are getting this error during build or during runtime?
i've tried re-deployment a couple of times.. it's possible there's an intermittent connection issue, i do not have adequate monitoring
2 years ago
try running your migrations during runtime with the private network
so the deployment i did 10m ago was successful, I had not changed anything
I just changed the database variable to use the internal one, and i'm getting the same error I was getting earlier:#12 1.987 Error: P1001: Can't reach database server at postgres.railway.internal:5432
2 years ago
change the runtime to v2 in the service settings
2 years ago
yep you beat me to it
2 years ago
is your postgres database in the same project and environment?
2 years ago
and are you now making the migration during runtime?
2 years ago
okay then we can try something else for that
2 years ago
you mean to ask if it is available during build, and the answer to that would be no, but lets try change that
2 years ago
add a service variable RAILWAY_BETA_ENABLE_BUILD_V2=1
2 years ago
more info:
2 years ago
for clarity the v2 runtime and v2 builder are separate systems
it does look like it got past the migration this time, so that appears to have worked
2 years ago
the v2 builder and v2 runtime aim fix so many things and bring so many improvements
2 years ago
what do your deploy logs look like?
2 years ago
what is the reason the health check fails?
2 years ago
what kind of app is this?
2 years ago
share your build and deploy logs please -
2 years ago
is there sensitive information in your logs?
2 years ago
with the username and password?
2 years ago
i mean you can edit the logs before you send them
2 years ago
do you have a PORT service variable set?
2 years ago
can you show me your app.listen?
2 years ago
yes it would be code
2 years ago
im just trying to work through some debug steps
2 years ago
if you arent interested in debugging this ill have to ask you to revert back to the legacy builder and make your migrations during runtime before starting your app
i'm interested in debugging this, but I'm a bit confused how that could help.. the only thing i can think of is:
either you think there's a bug in the code
you are trying to figure out whether the app is really listening to port 8080
you are wondering if the app is listening to only a particular host (it's listning to 0.0.0.0:8080)
and to those, i think it would be more efficient to ask me
2 years ago
ive been doing this for a while and screenshots of code is far more helpful than a written response
i'm sorry, i'm probably being rude, i'm sorry - in my defense it is 3 am here and i mostly just want to go to bed 🙂
2 years ago
thank you
2 years ago
now whats up with the build logs containing just the health check, and the deploy logs containing both the build and deploy logs?
yeah, that was weird to me.. because that's not what they look like in the UI
2 years ago
thats not an edit you did?
and i also had to click the bookmarklet twice.. first time it only downloaded that deploy log, second time it did this weird combo for the other file
i'm assuming it had something to do with the fact that i had the logs open at the time?
2 years ago
it calls railway's api, it doesnt scrape the web page
2 years ago
but im not sure whats going on with the failed health check, can you try removing the health check for now
2 years ago
do you have a deployment open?
2 years ago
interesting, ill have to look into this

yeah, if you open the deployment log.. it will give you the actual build log.. concatenated with the output of what should be the deployment log
2 years ago
it might not
2 years ago
this thread is good
2 years ago
no problem!
2 years ago
fwiw I fixed the bookmarklet, you just have to delete your old one and drag over the new one -
ok, so i've made the same changes in the dev environment, and it's failing the health check in the same way
--
Is anybody watching this thread?
Anyways, I'm still trying to debug this issue. I haven't made changes related to the active deployment, but it is now all of a sudden not able to connect to the database.
This is the same issue that's been happening on and off lately - and my initial suspicion for what was causing the failed migrations during deployment
Can't reach database server at monorail.proxy.rlwy.net:10861\n\nPlease make sure your database server is running at monorail.proxy.rlwy.net:10861.
I opened a new issue for this, since it's not really related to the build process
--
on to the previous issue, it looks like disabling the health check did not adversely affect things - and in the dev environment setting the database env var to the internal one + setting
runtime: V2
RAILWAYBETAENABLEBUILDV2=1
with the disabled health check it really does seem like everything is working and the service does get deployed successfully
But i'd really like to have the health check there.. in cases where for some reason I make a mistake and the service doesn't actually work
2 years ago
it was already 3:30am for me when I sent the message for the bookmarklet and I went to bed shortly after that
2 years ago
last night I went around enabling the v2 runtime on some services I had that were still using the legacy runtime, and my umami service started failing the health check with the same reason yours did, did you say your app was a nest app?
2 years ago
side note, I very much appreciate all the testing you've done!!
2 years ago
went to bed before i did more testing last night, but having umami listen on :: instead of 0.0.0.0 allowed the health check to pass and the service to come online without issue
2 years ago
cc @char8 runtime v2 health check oddities
did you say your app was a nest app?
not a nest app, but a fastify app - some nest setups use fastify - not sure if that's related, but it would seem strange if what software was running could affect the health check
2 years ago
it bugged me that it didnt work
2 years ago
i mean it shouldn't make sense, the health check should work for either ipv4 or ipv6
the service is probably not listening to incoming connections on ipv6, let me try this
2 years ago
ideally you would be able to listen on either ipv4 or ipv6 and the health check would work regardless
i should have read through this: https://docs.railway.app/reference/private-networking 🙂 could have saved me some hours
2 years ago
no no, you should not need to listen on ipv6 for the health check, thats a bug
2 years ago
but thats the current work around
it literally says:
You will need to bind to a IPv6 port to receive traffic on the private network.
2 years ago
right but the health check is not private networking
so this line that says that private networking is not available during the build phase, that's what will no longer be the case for the new builder?
2 years ago
thats correct
2 years ago
the v2 builder is now a part of the private network
i remember fighing this a bit when i was setting things up initially.. and distinctly remember giving up on the private network for the db connection, probably because of this..
so i might be able to make my db private-network only
2 years ago
thats the goal!
btw i really have been happy with railway in general and it has been really solid for me.. been using it now for two years - i think it's an excellent product and kind of overlooked in the dev community - fly.io etc grabbing all the attention
2 years ago
even though i dont work for railway, i appreciate that
and the bookmarklet .. that's just your own thing to made to make it easier to help people?
2 years ago
well i am a mod so i was told many weeks ago about that, but the info has since been made public
and yep the bookmarklet is my own thing, screenshots of code may be helpfull, but screenshots of build logs are rarely helpful
2 years ago
no one
2 years ago
nope
2 years ago
yeah!
well, i bought you some trains - let me know if there's ever anything i can help you with
2 years ago
thank you so much!! i appreciate that!!
btw the service was deployed successfully after changing the listening address.. so all problems resolved
2 years ago
thats awsome!
2 years ago
are you now using the private network to run your migrations during build and for regular communication during runtime?
2 years ago
sounds good!
btw the new build thing injects a bunch of extra lines into the logs:
INFO[0007] No files changed in this command, skipping snapshotting.do you know if there's a way to omit these?
i don't see this when building the docker image locally, so i'm not sure what that is
2 years ago
the v2 builder doesnt use buildx it uses something else entirely, and its a little more verbose, theres no way to omit that info
and thanks a lot for your help, i'm running on private networking both in the build and in the runtime 👍 both on dev & production
2 years ago
thats great, glad the health check issue was a simple fix
2 years ago
thats something a mod can only do, ill go find the best message to mark as the solution
2 years ago
to recap -
enable the v2 builder and the v2 runtime, if your health check fails, have your app listen on the :: host
2 years ago
well the bot is offline so i will mark that as the answer when the bot come back online
i can also summarize:
I was using the public network to run DB migrations during the build process. I started having connectivity issues when doing that. I made my service use the DB's private networking url and enabled the V2 runtime in settings and set the RAILWAY_BETA_ENABLE_BUILD_V2 variable to 1 - this resolved the issue
(there was a bug in the health check, where it was connecting to the service in the ipv6 range, so i had to also enable that for my app - but that was a separate issue)
2 years ago
yours is better, ill use yours


