{"record":{"id":"c44dbac62aa0824b","repo":"quarkusio/quarkus","slug":"unable-to-determine-datasource-url","errorCode":null,"errorMessage":"Unable to determine datasource URL","messagePattern":"Unable to determine datasource URL","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PsqlCommand.java","lineNumber":39,"sourceCode":"    public PsqlCommand(DevServicesLauncherConfigResultBuildItem devServicesLauncherConfigResultBuildItem) {\n        this.devServicesLauncherConfigResultBuildItem = devServicesLauncherConfigResultBuildItem;\n    }\n\n    @Override\n    public CommandResult execute(CommandInvocation commandInvocation) throws CommandException, InterruptedException {\n        //todo: should this work for non-dev services stuff as well? What about non-default datasources\n        try {\n            URI uri;\n            if (devServicesLauncherConfigResultBuildItem.getConfig().containsKey(JDBC_DATASOURCE__URL_KEY)) {\n                uri = new URI(\n                        devServicesLauncherConfigResultBuildItem.getConfig().get(JDBC_DATASOURCE__URL_KEY)\n                                .substring(\"jdbc:\".length()));\n            } else if (devServicesLauncherConfigResultBuildItem.getConfig().containsKey(REACTIVE_DATASOURCE__URL_KEY)) {\n                uri = new URI(\n                        devServicesLauncherConfigResultBuildItem.getConfig().get(REACTIVE_DATASOURCE__URL_KEY)\n                                .substring(\"vertx-reactive:\".length()));\n            } else {\n                throw new RuntimeException(\"Unable to determine datasource URL\");\n            }\n\n            int port = uri.getPort();\n            String host = uri.getHost();\n            String pw = devServicesLauncherConfigResultBuildItem.getConfig().get(\"quarkus.datasource.password\");\n            commandInvocation.println(\"PGPASSWORD=\" + pw + \" psql --host=\" + host + \" --port=\" + port + \" --username=\"\n                    + devServicesLauncherConfigResultBuildItem.getConfig().get(\"quarkus.datasource.username\") + \" \"\n                    + uri.getPath().substring(1));\n            return CommandResult.SUCCESS;\n        } catch (URISyntaxException e) {\n            throw new RuntimeException(e);\n        }\n    }\n}\n","sourceCodeStart":21,"sourceCodeEnd":54,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PsqlCommand.java#L21-L54","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure quarkus.datasource.jdbc.url (or reactive url) is set and that PostgreSQL dev services actually started (check dev console / logs)","Re-enable dev services (quarkus.datasource.devservices.enabled=true) or configure an explicit URL","Verify the datasource is Postgres and the app started in dev mode so DevServicesLauncherConfigResultBuildItem was produced","Check earlier dev services log errors — a container startup failure will leave the URL keys unset"],"exampleFix":"// before\n# no url anywhere -> throws\nquarkus.datasource.devservices.enabled=false\n// after\nquarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/mydb\n# or re-enable dev services\n# quarkus.datasource.devservices.enabled=true","handlingStrategy":"validation","validationCode":"var cfg = devServicesLauncherConfigResultBuildItem.getConfig();\nboolean hasUrl = cfg.containsKey(\"quarkus.datasource.jdbc.url\")\n        || cfg.containsKey(\"quarkus.datasource.reactive.url\");\nif (!hasUrl) throw new IllegalStateException(\"No JDBC or reactive datasource URL available for psql\");","typeGuard":null,"tryCatchPattern":"try {\n    psqlCommand.execute(invocation);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"Unable to determine datasource URL\")) {\n        // fall back to quarkus.datasource.jdbc.url from app config or instruct user to enable dev services\n    } else throw e;\n}","preventionTips":["Set quarkus.datasource.jdbc.url explicitly when dev services are disabled","Confirm PostgreSQL dev services started (dev console) before invoking psql","Only run the psql command for Postgres datasources"],"tags":["devservices","postgresql","datasource","config"],"backgroundTag":"missing-datasource-url","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}