I cannot access my render-hosted Postgres database from a background worker.
This is the error when testing via the shell:
$ psql --host=dpg-abc
psql: could not translate host name "dpg-abc" to address: Name or service not known
Note that if I execute the same command from my web service, everything is fine:
$ psql --host=dpg-abc
Password for user render:
I can’t find anything in the docs to indicate that render hosted databases cannot be accessed from background workers. Have I missed something? Currently the database access control is open to the world so I don’t think it relates to this - and if I use the external connection string within my background worker instead, everything is fine - but this isn’t ideal for production.
Hi @mtford, there shouldn’t be any difference between connecting to your database from a web service and connecting from a background worker. In both cases you can use the internal connection string to reach your database securely within a private network. I suspect that the issue was due to an intermittent DNS resolution failure. Would you mind trying again and reporting back? Thanks for your help with this.
@david - do let me know what I can do to help debug this further, happy to jump on a call or whatever to demonstrate or else supply you with the server identifiers etc.
Hey @mtford, one thing to check when using the internal connection string for a database: is the database in the same region as the service/worker that’s trying to connect?