Issue with Postgres on deployment. ECONNREFUSED
Hello,
I have an issue that the railway service seems to not connect to the Postgre database even though the DATABASE_URL env variable passed to the program is all correct in correct order as well, so I am suspecting something wrong with my railway setup.
The full error log:
It might be useful to know that the Postgre database server (also deployed in Railway) says that its running on 0.0.0.0 and port 5432. thanks for all help! Project id: 578ca578-fb97-4683-b8ef-2c59b4a09608
276 Replies
Project ID:
578ca578-fb97-4683-b8ef-2c59b4a09608
in initial deploy logs, all seems fine
however, in the active logs the errconnect issue comes up. I can share any part of the code / log if it helps
show me your service variables please
sure thing
those are shared variables
why are all your variables there
i thought it convenient to share to the services then
I do have them in the individual services too
does more than one service need to access those variables
no
only the backend
(1)
then remove them from the shared variables please
allright, ill do that
done
show me a full screenshot of your browser window open to your railway project
π€
delete database_url
from the service...?
yes
done
and then setup the variable reference for it like that blue banner wants you to, then show me another screenshot
please specify blue banner?
will it come after deployment process is done (failure i figure)
I'm colourblind, is that banner that's talking about variables references not blue?
ah yes, its kinda purple, blue enough π
blue is enough, yes
okay do that
like this, right?
yes
good
now show me the bit of code that connects to the database
here you go
I got it printing "Database connection successful" before lol
(initial deploy logs)
so.. good?
nope, the error still comes with the localhost lol
show me
the error wasnt in the database URL
fair, but you where doing that wrong so it needed to be done regardless
yeah, of course
well do you know what bit of code is throwing that error?
absolutely not
got a repo I could look at
there shouldnt be any issue
I can send the code in a zip
repo's piv
lmfao you don't use github?
priv
i do
oh priv
was about to say based for the fact of not using github
yeah zip is fine
I'll take a look when I'm on my computer in a bit
allright, np
send the zip in the mean time tho
ive went through it a billion times
haha
I'll give it a good run down
where it go
theres no reference to localhost in any of the code
i dont understand where its coming from at all
send the code
I did, check DM
#πο½readme #5
?
did you read #5 of the readme
yes but I thought youd allow me not having to put it out here
you want me to post it here nevertheless?
dm'ing me breaks server rules
yeah lets not break it then
yes, no one is gonna steal your code
tell me if you can get it
okay now don't randomly delete it, I'll need to download it later when I'm on my computer
allright, np
ETA?
eta is 9 hours
let's not ask community help for an eta please
do youve any idea what could cause the issue so i can troubleshoot meanwhile harder?
I'm joking
a slightest guess would help
I'm not joking
no clue at all
the ip it tries to connect to the database, that shouldnt even be possible right tho?
i was not tryna be rude sorry
when i start the database it runs ipv4 on 0.0.0.0
yeah I know, but that's irrelevant because database_url will contain it's public address
yeah, I figure so
I can connect to the database from psql client as well
yep
all i can think of logically is a faulty query
but theres none
where localhost is hardcoded
ill do my best to see whats up
appreciate it
ill do too π
whats with the runtime.txt
its legacy along with procfile
from h*roku
the frontend is done with python
show me your .env file please, blur the sensitive stuff
what do you want to know exactly? it can get all of them but the issue must be with the postgresql in railway
its not postgre, the console logs said it cconnected
what else can it connec tto with 5432 port :/
why do you have 5432 in your .env file
to specify the port just in case
i can remove it but it wont be the solver lol
also my other postgre instance i tried with runs in another service with that
does this app start an http server
it shouldnt no
I havent defined or generated any links for it
in railway either
okay
it recomended me to do that once, with some flyer that said "listening on 127.xxxxxx, try 0.0.0.0"
which seemed like a nice solution but it led me nowhere since I didnt know how to implement that
then i generated a random domain to the service to "expose" it but didnt help
"The easiest way to get up and running is to have your application listen on 0.0.0.0:$PORT, where PORT is a Railway-provided environment variable."
you are running a bot
thats not applicable
yeah, I guessed so immediately
but still because i saw the server ip in 0.0.0.0 and I dont know much about how the docker is setup, if its in the same server so i begun believing in witchcraft
full deploy logs please
@GNUumer
sure thing
could i download them somehow?
no, copy paste into txt file and send that file here
gotcha
@Brody
its three times in a row
if you need it, I can redeploy, test stuff, anything im here for it. personally ran out of solutions
add a
console.log(process.env.DATABASE_URL);
before the new Pool
line in db/index.js
good idea, doing it ASAP
(meaning rn)
im not seeing a
!!Database connection successful!!
log in your logfileI sent the log from the instance
the log from the deploy is different
it has this stuff running all the time
and the console.log should be in that there above as well
or will be
what is the difference between instance and deploy
i was hoping someone could tell me that too lol
the "deploy logs" have that above there
you said it, im asking you
while the "restart logs" have this here
so when I click one of the times it restarts forcefully, I can see these logs
sorta like the server log
where is this from
server log, here
when i click one of the restart messages and go deploy log
wtf is a restart message
quite literally that
i click it, go to "deploy logs" and see the errors
otherwise theres no error in the actual "instance log"
bruh
so for example, i click the latest deploy restarted so I could get a whiff of whats going on
but then the actual deploy logs be looking like this
just show me the log for this
there we go
catching it all in a file now...
and it keeps going on like that, as if theres no problem
theres no errors
errors are there
it forces deployment again and again
well then remove the cluster stuff
and then when I click why, i get this
elaborate abit
what exactly you want me to get rid of?
why do you have cluster stuff
you mean those multiple services or?
cluster.fork();
whywhere is that?
app.js
that part wasnt written by me. youre saying to remove all of it?
and why exactly?
its dumb stuff
but first
allright, I'll do it for test
set restart policy to never
allright
dont remove code yet
though its still very much spagetti
yeah, im doing it in that order
sorry about that π
who wrote it, if you didnt
i have 4 (3) members in the team
i only do the backend stuffs
thats where the "issue" is anyhow
you are not on the teams plan though?
I am
should be?
oh yeah, I was on the teams plan, but then it didnt work and I had to enable my own starte rplan
teams there anyhow
got it
youre safe
im just an amateur im not a criminal trust me π
i set it to never redeploy, but its restarting anyhow
so must be a crash forcing it to do so
okay remove the cluster code
I did just that
it redeployed and then immediately restarted
send new code?
do you want the logs from the deploy?
allr
short enough to put here
okay, logs please
incoming
but same issue persists
any chance this could be with the postgres after all?
this is a postgre error, yes
if it helps (its obvious): if i restart the service, its a crash
yeah
you have this code in a repo right?
i do on my branch
what branch do you have the service linked to
exactly that
okay, remove that entire service
you sure? π just to double check
yep, remove it
aight
then create an empty service and setup your variables, and link the repo and set the branch
I'll take a quick bathroom break and do exactly that
thank you really for your fortitude in trying to help π
logs just before it crashed if that helps
it still somehow tries to redeploy it on and on even though its crashed and set to never
have you set up your variable references
and added the api keys
yup
do you see this anywhere anymore?
yes, exactly the same error pops up and forces the redeployment
why dont i see it in here
its before the crash from the other deployment log
i only care about the most recent
allright, well that it the most recent
this
i dont see that console log for the database_url
its in the other log
its there
okay and why is railway deploying different versions of your code
and its constantly updating those successful database connections. so I am quite sure this must be an issue with the posgres on render
its not at all
then why are there two different logs
the other one is like this:
i figure its just the relevant parts snipped there
but if youre positive that doesnt happen well then... then that could be the issue likely
?
because the other is the deploy log I see when its relaunching
and the other one is the actual "normal" one with no immediate errors whatsoever
show me a screenshot of the metrics please
forcibly redeploying
gotcha
um
1. why does it use 2.6gb
2. how can it use 2.6gb, you are on the free plan
im not on the free plan, the service is paid by someone who has put more money into it. I am developing it
as to why it uses 2.6gb, it can be the load from the APIs, but still its high
I will send you the error log now from the deployments Deploy Logs
full browser screenshot of project please
aight
anything specific?
free plan
thats not what the project runs on though
its just my account
youre deploying this under the teams account?
my account connected to the teams yeah
that i believe would imply it that it has the team there
screenshot of dashboard please
theres teamplan
you gotta change that name lmfao
which name?
fertile
ill pass the suggestion upwards
I think its nice
how can railway just decide to redeploy at crash even though i set it to never?
im sorry, i give up
but good news
throw me
your on teams plan
ask the team π
do you think I can contact them here?
id ping them, but they are both idle
can I use this thread?
just asking about the methods normally used
yeah this thread is fine, ill ask them in mod chat, no promises on when someone will be able to help you though
gotcha
thanks for your effort!
sorry i couldnt help
ah, server prohibits pinging them
i tried angelo and jitachi, theyve the team plan tag
yeah do not ping the team under any circumstance
against the server rules
Heya. Iβll look into this shortly
hey, thanks alot! I'm here if you need me
the code or else, though I am quite certain the code should run, the issue must be at the DB configurations end or alike ;/
just read through this, so the issue is you're unable to connect to Postgres even though everything seems to be correct?
ah it's the restarting issue..
FYI I deleted a bunch of messages in this thread + the zip you uploaded that contains your Postgres creds and a bunch of API keys
yeah, nope
is it a known issue? because I really cannot find anything on my end
I was ""scared"" Brody wouldnt help me otherwise, we'll setup the credentials again once we can get it working on some level of course along with SSL
also rc it does interest me as well how there can be two deploy logs, because should they not be quite exactly the same if both are run with the same start command from the same repo? or is it a feature on your end to have a separate deploy log in for specific deployments
thats what i wanna know, and thats ultimately the reason i asked the team to come assist
you made a fair point there, I had just accepted there were two logs and one had the issue
thinking now its not that clear it should be so π
yeah see why i was so confused
you know the error with 127.0.0.1 in it, thats an error you would get if you created a pool with no credentials, or empty connectionString
also, you are creating a new pool during every import, thats why you are seeing multiple prints of connection success, so please work on getting the database pool setup correctly
how is that possible?
yeah, but shouldnt be so :/
afaik all the queries just re-use the one pool connection?
every time you import db/index.js it creates a new pool
I killed the container for that deployment
the service was deleted and for some reason that wasn't removed
not showing up on my end yet...
fixed that but did not affect the redeploying issue unfortunately at all
now theres only one. thanks @Brody π
did you delete the service previously?
once, only the backend service
it did nothing unfortunately
so, the connection didn't work -> it keeps restarting -> you delete the service -> deployment still keeps restarting?
(PurpleBuyBot service)
@Cooper
yes. and it restarts even if I put restart on failure to never!
is this a CLI deploy?
uhh no I figure? I do it with the sites GUI
elaborate on that if you can or need to
you deleted the service through dashboard?
we're debugging this rn π
yes sir
only used the dashboard for that, wouldnt dare to do otherwise hah
gotcha!
it deployed from github btw
yes I set it from there
only ever done that
I see. weird that it crashed
that's the ideal state, it was supposed to crash and never restart π
hahahah
well it looks to be online/active now
only thing im worrying about is, does it remove the deployment just made?
no it doesn't, that happened because you pushed a new build
only one deployment can be running at a time
new deploy = old deploy gets removed π
ah, gotcha. just in a creepy order π
thanks alot guys at team and Brody