quarkusio/quarkus · error · RuntimeException

Unable to determine datasource URL

Error message

Unable to determine datasource URL

What it means

PsqlCommand generates a shell command to connect to the dev-services PostgreSQL database using psql. The datasource URL is taken either from the JDBC url (quarkus.datasource.jdbc.url, stripping the jdbc: prefix) or the reactive url (stripping vertx-reactive:). If neither key exists in the DevServicesLauncherConfigResultBuildItem config, it cannot determine where to connect and throws this RuntimeException.

Solutions

  1. Ensure quarkus.datasource.jdbc.url (or reactive url) is set and that PostgreSQL dev services actually started (check dev console / logs)
  2. Re-enable dev services (quarkus.datasource.devservices.enabled=true) or configure an explicit URL
  3. Verify the datasource is Postgres and the app started in dev mode so DevServicesLauncherConfigResultBuildItem was produced
  4. Check earlier dev services log errors — a container startup failure will leave the URL keys unset

Example fix

// before
# no url anywhere -> throws
quarkus.datasource.devservices.enabled=false
// after
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/mydb
# or re-enable dev services
# quarkus.datasource.devservices.enabled=true
Defensive patterns

Strategy: validation

Validate before calling

var cfg = devServicesLauncherConfigResultBuildItem.getConfig();
boolean hasUrl = cfg.containsKey("quarkus.datasource.jdbc.url")
        || cfg.containsKey("quarkus.datasource.reactive.url");
if (!hasUrl) throw new IllegalStateException("No JDBC or reactive datasource URL available for psql");

Try / catch

try {
    psqlCommand.execute(invocation);
} catch (RuntimeException e) {
    if (e.getMessage().contains("Unable to determine datasource URL")) {
        // fall back to quarkus.datasource.jdbc.url from app config or instruct user to enable dev services
    } else throw e;
}

Prevention

When it happens

Trigger: Running the psql command integration in dev mode while the dev services config result contains neither quarkus.datasource.jdbc.url nor quarkus.datasource.reactive.url — e.g. dev services produced no URL because the datasource is disabled, misconfigured, or start failed.

Common situations: quarkus.datasource.devservices.enabled=false with no explicit jdbc.url; a dev services startup failure that skipped populating the config; using a datasource kind the command does not recognize; invoking the psql launch command for a non-PostgreSQL datasource.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/c44dbac62aa0824b. Report an issue: GitHub.

Appendix: source

Thrown at extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PsqlCommand.java:39

    public PsqlCommand(DevServicesLauncherConfigResultBuildItem devServicesLauncherConfigResultBuildItem) {
        this.devServicesLauncherConfigResultBuildItem = devServicesLauncherConfigResultBuildItem;
    }

    @Override
    public CommandResult execute(CommandInvocation commandInvocation) throws CommandException, InterruptedException {
        //todo: should this work for non-dev services stuff as well? What about non-default datasources
        try {
            URI uri;
            if (devServicesLauncherConfigResultBuildItem.getConfig().containsKey(JDBC_DATASOURCE__URL_KEY)) {
                uri = new URI(
                        devServicesLauncherConfigResultBuildItem.getConfig().get(JDBC_DATASOURCE__URL_KEY)
                                .substring("jdbc:".length()));
            } else if (devServicesLauncherConfigResultBuildItem.getConfig().containsKey(REACTIVE_DATASOURCE__URL_KEY)) {
                uri = new URI(
                        devServicesLauncherConfigResultBuildItem.getConfig().get(REACTIVE_DATASOURCE__URL_KEY)
                                .substring("vertx-reactive:".length()));
            } else {
                throw new RuntimeException("Unable to determine datasource URL");
            }

            int port = uri.getPort();
            String host = uri.getHost();
            String pw = devServicesLauncherConfigResultBuildItem.getConfig().get("quarkus.datasource.password");
            commandInvocation.println("PGPASSWORD=" + pw + " psql --host=" + host + " --port=" + port + " --username="
                    + devServicesLauncherConfigResultBuildItem.getConfig().get("quarkus.datasource.username") + " "
                    + uri.getPath().substring(1));
            return CommandResult.SUCCESS;
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }
}

View on GitHub (pinned to e1c734241f)