Having issue connecting Render hosted Rails application to postgres on Render

I am trying to connect a Rails application on Render with a Postgres db also on Render.

When I try to run the migrations during my application build I get the following error: PG::ConnectionBad: could not translate host name ‘host-name’ to address: Name or service not known. Where ‘host-name’ is my pg database’s host name.

I am using the database url generated by Render for use with applications hosted on Render, but it seems that it’s not working. I have a YAML set up linking my application with the database.

I would truly appreciate any help!

@Tommy_Lawrence It looks like your service is hosted in Oregon and your database in Frankfurt. This was likely an accident in the YAML file, leaving the service’s region empty and it defaulted to Oregon.

1 Like

One additional note: if you ran into this because you created your db in a region other than Oregon and did not specify a region in your render.yaml file (like me), in addition to adding the line in the render.yaml (details here), you will also need to delete and re-create your blueprint and web service via the render UI (it won’t work if you simply add the line to the yaml file and re-deploy).