Postgresql connection issues

I made a postgres instance on render and am trying to connect to my database externally, however I am getting this error

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at “dpg-ck0mhij6fquc73862au0-a.oregon-postgres.render.com” (35.227.164.209), port 5432 failed: Connection timed out (0x0000274C/10060)
Is the server running on that host and accepting TCP/IP connections?

Hi,

If you’re connecting to a Postgres DB from outside Render, this is covered in the docs here:

https://render.com/docs/databases#connecting-from-outside-render

You’d need to plug these details into SQLAlchemy. Which I think also requires the scheme to be postgresql:// (not postgres://). You’ll also need to ensure the SSL mode is set to true/require.

Lastly, ensure the Access Control settings on the database are set as expected, e.g. correct/valid IP range.

Alan

Thanks for the reply.
I have all of that setup already. How would I check/change the ssl mode? The Access control list i have right now is set to 0.0.0.0/0. is that correct?

0.0.0.0/0 would be correct to allow external access from any IP.

I’m not a SQLAlchemy user, but a quick search for SQLAlchemy SSL mode brought up this StackOverflow answer: https://stackoverflow.com/a/69984998

We’d suggest require over allow in the example.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.