Hi! I have issues when trying to connect to my database from my local Flask project, but the project in production works fine and connection to the database without problems.
Right now I have the same changes that I have in production.
In my local I have this error:
connection to server at “db.fly.dev" (xxx.xxx.xxx.xxx), port 5432 failed: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
I’ve worked without problems until today
Hi… For local development, it’s best to tunnel through with flyctl proxy. That way, you avoid exposing your database to the public Internet,
.
https://fly.io/docs/postgres/connecting/connecting-with-flyctl/
Keep that command running in the terminal for as long as you need the tunnel.
Hope this helps!
Cool, one question, is recommend to have a ipv4?
I would remove it, if all it was needed for was local development.
(Apart from the security aspect, it’s also costing you $2/month.)
Got it, but, I have my application in production.
Remove it from the database app, I mean.
(Your production app would generally be using .internal or .flycast instead of .fly.dev to contact Postgres.)