Celery/Django app failure connecting to Postgres over private network

Project ID: f8880a56-7cb0-4ceb-891a-48baf9c79599 Hi, I've been trying for a good amount of time now to connect my django/celery app to postgres over the private url instead of the public one, but I always seem to land on the same error. Have already read through many of the threads here on the help section and tried things like the sleep but did not help. I am also not on an alpine based image, I am using python:3.11-slim which is based on debian. I am however able to connect to redis via the private URL with no issue. On the screenshots you can see that I am sleeping for 3 seconds (tried even with 10 seconds and got nothing) You can also see that redis connects correctly and I do receive one of the scheduled tasks. And then you can finally see one of these tasks failing out due to an operational error, with "port 5432 failed: server closed the connection unexpectedly." Any assistance I can get with this?
No description
No description
No description
17 Replies
Percy
Percy13mo ago
Project ID: f8880a56-7cb0-4ceb-891a-48baf9c79599
Luis Vieira
Luis VieiraOP13mo ago
Project ID: f8880a56-7cb0-4ceb-891a-48baf9c79599
Brody
Brody13mo ago
I am however able to connect to redis via the private URL with no issue.
maybe a silly question, but can you also connect to postgres over the public network?
Luis Vieira
Luis VieiraOP13mo ago
Yes, and that is how everything is working right now. I have fully switched redis over to private networking, but I had to keep postgres using the public one because if I switch to private it just fails with the error from one of the screenshots above.
Brody
Brody13mo ago
if the postgres client in use compatible with an ipv6 network?
Luis Vieira
Luis VieiraOP13mo ago
That's honestly a good question. I just use psycopg which is as far as I am aware, the only one, or at the very least the king of the hill of python postgres clients In nearly 15 years of developing with python I've never used any other, or heard tbh.
Brody
Brody13mo ago
and you're just using DATABASE_PRIVATE_URL right?
Luis Vieira
Luis VieiraOP13mo ago
yeah
Luis Vieira
Luis VieiraOP13mo ago
I just swap that DATABASE_URL to DATABASE_PRIVATE_URL
No description
Brody
Brody13mo ago
is there anything unusual in the database logs?
Luis Vieira
Luis VieiraOP13mo ago
Let me swap the variables and look at the postgres logs
Luis Vieira
Luis VieiraOP13mo ago
restarted the postgres deployment, just to be sure, and the service is now redeploying after variable swap.
No description
No description
Luis Vieira
Luis VieiraOP13mo ago
it is giving me some suspicious logs.
No description
Luis Vieira
Luis VieiraOP13mo ago
Im gonna try redeploying it Interesting, after redeploying it (the postgres db, not the service), things seem to be working. Im wondering if there was some issue with the first deploy post-migration. ( did just migrate this from a legacy db last night)
Brody
Brody13mo ago
that's very odd, but glad it's working now!
Luis Vieira
Luis VieiraOP13mo ago
yeah, I have no idea what happened here, but it just worked after redeploying the postgres db. Could have been some weird artifact of the migration 🤷‍♂️
Brody
Brody13mo ago
that's very possible
Want results from more Discord servers?
Add your server