Unable to use internal PostgreSQL hostname (external works fine)

Hi all,

I am attempting to deploy a Spring Boot application via a Blueprint. The app requires a connection to a database. This works fine on local. But if I define a Blueprint with the database and web service, the deployment fails with:

Caused by: java.net.UnknownHostException: <internal url>

Curiously, if I manually update the hostname to the external one, the service is able to connect. This would be fine, but it does not seem that RENDER_EXTERNAL_HOSTNAME is available for databases.

Any guidance on how to resolve/workaround this issue is greatly appreciated.

Config

My render.yaml looks a bit like this:

services:
  - type: web
    name: my-app
    env: docker
    envVars:
      - key: DATABASE_HOST
        fromDatabase:
          name: db
          property: host
      - key: DATABASE_SCHEMA
        fromDatabase:
          name: db
          property: database
      - key: DATABASE_USER
        fromDatabase:
          name: db
          property: user
      - key: DATABASE_PASSWORD
        fromDatabase:
          name: db
          property: password

databases:
  - name: db

application.yml like this:

spring:
  datasource:
    url: jdbc:postgresql://${DATABASE_HOST:localhost}:5432/${DATABASE_SCHEMA:postgres}
    username: ${DATABASE_USERNAME:postgres}
    password: ${DATABASE_PASSWORD:postgres}
    driver-class-name: org.postgresql.Driver

And Dockerfile for the service looks like this:

FROM maven:3.8.6-eclipse-temurin-19-alpine AS maven
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN mvn package -Dmaven.test.skip

FROM eclipse-temurin:19-jdk-alpine
ARG JAR_FILE=my-app.jar
WORKDIR /opt/app
COPY --from=maven /usr/src/app/target/*.jar /opt/app/${JAR_FILE}
ENTRYPOINT ["java","-jar","my-app.jar"]

Hi there,

An internal database URL not working usually points to the services being in different regions. To use the internal/private network the services need to be in the same team/account and region.

Although it’s hard to diagnose when all the real information has been redacted, if you still require assistance, please feel free to raise a ticket from the “Contact Support” link at the bottom of the Dashboard.

Alan

Different regions was indeed the problem. I had my web service set to the ohio region but neglected to add one to the database, which defaulted to oregon.

I can see this in the official documentation. Wish I had seen that before.

Anywho, thank you for the help!