29 Replies
Project ID:
2ff8f070-ab0c-4ee7-9676-2d3b36a36e0f
wow
it auto detected
dont know why but its not getting connected
my service is down and i want to make it active again : ( urgently
this is how i am connecting to db
i really need to get this service up quickly : (
@Anubhav
Make sure you're giving enough time for the private network to initialize.
Currently, private networks take up to 3 seconds to initialize on deploy. ... If you experience errors like those above, consider implementing a sleep or other wait mechanism in your app, before attempting to connect.https://docs.railway.app/guides/private-networking#initialization-time
i am using poetry run start does it will support sleep?
sleep 3 && poetry run start
right?I'm not familiar with poetry sorry so I'm not sure what the command would be.
: (
In my program I just check to see if the DB connection failed and then try again in 5 seconds. That fixed it for me.
ok i just deployed with sleep 3 hoping to work
i have added asyncio.sleep at my connect method
so it waits
hopefully it works
i am still getting same warning
not fixed at all
my code
: (
Does this work locally? I'm not seeing in your code where you're getting the env variable (I'm assuming you're using an env variable to pass your DB private URL to your application).
it does work locally
and works perfectly : (
i am not able to establish connection on railway for some reason
If you print out
DevCreds.DEV_SITE_PASSWORD
does it print out what you expect?yep
its another api creds
Also the private url isn't just the password. It's the full connecction string.
i referenced it
Does it work locally if you use the public connection string?
i have not connected to railway db locally , i use local db for bot for testing only for production i use railway db
I'd try connecting to your railway db locally. There is a public connection string you can use.
So run your app locally and use the public connection string to connect to that Postgres instance.
ok i will try
it connected succsfully
but at railway its different
thats failing there
so locally railway db works but when i try to connect with app it doesnt
@𝐗-𝐥𝐞𝐦
2024-08-12 21:08:18.540 | WARNING | afw_bot.ext.utils.database:connect:14 - 2024-08-12 21:08:18 Failed to connect to the database: Multiple exceptions: [Errno 111] Connect call failed ('::1', 5432, 0, 0), [Errno 111] Connect call failed ('127.0.0.1', 5432)
i changed to public url which is not 5432 still it showing this only
port should be 40317
The connection string should have the port already? Where are you seeing the port is wrong? In the DB env variables?
in the error
connection string have 40317 port
Check the DB service env variables. That's probably the port it's using.
you are right but when i copy the public url why it has different port?
and i am able to connect with the 40317 port in my program locally on my pc
I'm assuming one's the internal port and one's the external port.
If your AFW-bot has an env called
Core.DATABSE_URL
and it's set to ${{Postgres.DATABASE_URL}}
then it should work. I'm not sure what else the issue would be :/this is exactly what i tried but it didnt connected on railway but locally with public url it did connect
@𝐗-𝐥𝐞𝐦 i am very sorry i wasted your time and i seriously apologize for this , being a absolute stupid person i mispelled a letter in my actual code DATBSE_URL and tried to connect with DATABASE_URL
its connecting now
😛
spelling mistakes kill us all
literally wasted 4h for nothing
Did you not have that spelling mistake locally?
actually suggestion from my IDE
it suggested me wrong as i have created wrong var name at starting
so i didnt noticed