alibaba/druid · error · IllegalArgumentException

Cannot load remote config file from the [config.file={config

Error message

Cannot load remote config file from the [config.file={configFile}].

What it means

loadPropertyFromConfigFile throws this when a config.file (or druid.config.file system property) was supplied and non-empty, but loadConfig(configFile) returned null. loadConfig returns null only when it cannot open/read/parse the resource for any scheme (file://, http(s)://, classpath:, or bare path). So the path was set but unreachable.

Source

Thrown at core/src/main/java/com/alibaba/druid/filter/config/ConfigFilter.java:168

        return Boolean.valueOf(decrypterId);
    }

    Properties loadPropertyFromConfigFile(Properties connectionProperties) {
        String configFile = connectionProperties.getProperty(CONFIG_FILE);

        if (configFile == null) {
            configFile = System.getProperty(SYS_PROP_CONFIG_FILE);
        }

        if (configFile != null && configFile.length() > 0) {
            if (LOG.isInfoEnabled()) {
                LOG.info("DruidDataSource Config File load from : " + configFile);
            }

            Properties info = loadConfig(configFile);

            if (info == null) {
                throw new IllegalArgumentException(
                        "Cannot load remote config file from the [config.file=" + configFile + "].");
            }

            return info;
        }

        return null;
    }

    public void decrypt(DruidDataSource dataSource, Properties info) {
        try {
            String encryptedPassword = null;
            if (info != null) {
                encryptedPassword = info.getProperty(DruidDataSourceFactory.PROP_PASSWORD);
            }

            if (encryptedPassword == null || encryptedPassword.length() == 0) {
                encryptedPassword = dataSource.getConnectProperties().getProperty(DruidDataSourceFactory.PROP_PASSWORD);

View on GitHub (pinned to fa8dc99126)

Solutions

  1. Verify the exact path/URL in config.file resolves from the JVM's working directory and classloader.
  2. For file://, check filesystem permissions and that the path is absolute or correctly relative.
  3. For http(s)://, curl the URL from the host and confirm a 200 with valid properties body.
  4. For classpath:, confirm the resource is packaged in a JAR on the classpath.
  5. Ensure the file is valid Java .properties or .xml properties format.

Example fix

// before
// ds.setConnectProperties({"config.file": "http://cfgsrv/druid.conf"}); // 404

// after
// ds.setConnectProperties({"config.file": "http://cfgsrv/druid.properties"}); // valid
Defensive patterns

Strategy: validation

Validate before calling

Properties probe = new ConfigFilter().loadConfig(configFile);
if (probe == null) throw new IllegalStateException("config.file unreadable: " + configFile);
// ensure reachable BEFORE wiring it into the datasource

Try / catch

try {
    ds.setFilters("config"); ds.init();
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Cannot load remote config file")) {
        // fix path/URL/scheme/permissions, then retry
    }
    throw e;
}

Prevention

When it happens

Trigger: config.file is configured (connection property, system property druid.config.file) and loadConfig returns null: file does not exist / unreadable, HTTP URL returns non-200/empty body, classpath resource absent, or the content is unparseable as .properties/.xml.

Common situations: Wrong path in config.file; the app lacks read permission on the file; an http config endpoint is down or behind auth; classpath: resource is in a JAR that is not on the runtime classpath; a typo in the URL scheme.

Related errors


AI-assisted analysis of alibaba/druid@fa8dc99126 (2026-08-14). Data as JSON: /api/errors/6d03423ea9b9c538. Report an issue: GitHub.