dgraph-io/dgraph · error
Minio handler requires a host
Error message
Minio handler requires a host
What it means
In the 'minio' scheme branch, NewMinioClient requires a host in the URI because Minio deployments are self-hosted and there is no default endpoint (unlike Amazon S3). An empty host means the client would not know which server to connect to, so construction fails immediately.
Source
Thrown at x/minioclient.go:102
}
func NewMinioClient(uri *url.URL, creds *MinioCredentials) (*MinioClient, error) {
if len(uri.Path) < 1 {
return nil, errors.Errorf("Invalid bucket: %q", uri.Path)
}
glog.V(2).Infof("Backup/Export using host: %s, path: %s", uri.Host, uri.Path)
// Verify URI and set default S3 host if needed.
switch uri.Scheme {
case "s3":
// s3:///bucket/folder
if !strings.Contains(uri.Host, ".") {
uri.Host = defaultEndpointS3
}
default: // minio
if uri.Host == "" {
return nil, errors.Errorf("Minio handler requires a host")
}
}
secure := uri.Query().Get("secure") != "false" // secure by default
if creds.isAnonymous() {
mc, err := minio.New(uri.Host, &minio.Options{Secure: secure})
if err != nil {
return nil, err
}
return &MinioClient{mc}, nil
}
var credsProvider *credentials.Credentials
if Config.SharedInstance {
credsProvider = credentials.New(MinioCredentialsProviderWithoutEnv(requestCreds(creds)))
} else {
credsProvider = credentials.New(MinioCredentialsProvider(uri.Scheme, requestCreds(creds)))View on GitHub (pinned to 759e242be6)
Solutions
- Include the Minio server host in the URI, e.g. minio://minio.example.com:9000/mybucket
- Check the endpoint configuration/env var for a missing or truncated host
- If you actually mean Amazon S3, use the s3 scheme so defaultEndpointS3 is applied
Example fix
// before
u, _ := url.Parse("minio:///backups") // no host
client, err := NewMinioClient(u, creds)
// after
u, _ := url.Parse("minio://minio.internal:9000/backups")
client, err := NewMinioClient(u, creds) Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(rawURI)
if err != nil { return err }
if u.Scheme != "s3" && u.Host == "" {
return fmt.Errorf("minio endpoint requires a host: %q", rawURI)
} Type guard
func hasHost(u *url.URL) bool { return u != nil && (u.Scheme == "s3" || u.Host != "") } Prevention
- Use the s3 scheme only for real Amazon S3 endpoints; self-hosted Minio must carry its host
- Validate endpoint env/config at startup, before storage clients are built
- Include host and port (e.g. minio.internal:9000) in connection strings
When it happens
Trigger: Calling NewMinioClient (directly or via NewFileStore, NewS3Handler, newRemoteExportStorage) with a minio URI with empty host and a non-'s3' scheme, e.g. 'minio:///mybucket' or 'http:///bucket'.
Common situations: Minio endpoint config missing the host part ('minio://bucket' instead of 'minio://minio-host:9000/bucket'), a truncated URL in a config file, or DNS/proxy setups where the host was stripped during URL parsing.
Related errors
- Invalid bucket: %q
- Failed to read s3 object
- Failed to read the s3 object
- While renaming object in s3, copy failed
- Rename failed to remove temporary file
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/51d8cdf15426f6ba.
Report an issue: GitHub.