juicedata/juicefs · error
Failed to create bucket %s: %s, previous error: %s
Error message
Failed to create bucket %s: %s, previous error: %s
What it means
The initial Put failed, the store's Create (bucket creation) attempt also failed, and the original error was NOT NoSuchBucket — so JuiceFS reports the create-bucket failure together with the original Put error without the manual-creation hint. This indicates a general connectivity/auth problem rather than a missing bucket.
Source
Thrown at cmd/format.go:344
b := make([]rune, n)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := range b {
b[i] = letters[r.Intn(len(letters))]
}
return string(b)
}
func doTesting(ctx context.Context, store object.ObjectStorage, key string, data []byte) error {
if err := store.Put(ctx, key, bytes.NewReader(data)); err != nil {
if strings.Contains(strings.ToLower(err.Error()), "denied") {
return fmt.Errorf("Failed to put: %s", err)
}
if err2 := store.Create(ctx); err2 != nil {
if strings.Contains(err.Error(), "NoSuchBucket") {
return fmt.Errorf("Failed to create bucket %s: %s, previous error: %s\nPlease create bucket %s manually, then format again.",
store, err2, err, store)
} else {
return fmt.Errorf("Failed to create bucket %s: %s, previous error: %s",
store, err2, err)
}
}
if err := store.Put(ctx, key, bytes.NewReader(data)); err != nil {
return fmt.Errorf("Failed to put: %s", err)
}
}
// GLACIER storage class doesn't allow read after write
if _, ok := ctx.Value(object.TierKey{}).(uint8); ok {
return nil
}
p, err := store.Get(ctx, key, 0, -1)
if err != nil {
return fmt.Errorf("Failed to get: %s", err)
}
data2, err := io.ReadAll(p)
_ = p.Close()
if err != nil {View on GitHub (pinned to c9a67b23e8)
Solutions
- Check both errors: the create error usually reveals the root cause (auth vs network)
- Validate credentials with the provider CLI against the same endpoint
- Test endpoint reachability: `curl -v https://endpoint`
- For S3-compatible stores, confirm the provider supports the ListBuckets/CreateBucket semantics JuiceFS uses
Example fix
// before --storage-url s3://bucket (endpoint misspelled) // after --storage-url s3://bucket --endpoint https://s3.us-east-1.amazonaws.com (correct endpoint)
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight: verify auth and endpoint // aws s3 ls s3://mybucket --endpoint-url $ENDPOINT
Type guard
func isCreateFailed(err error) bool {
return err != nil && strings.Contains(err.Error(), "Failed to create bucket") && !strings.Contains(err.Error(), "NoSuchBucket")
} Try / catch
err := doTesting(ctx, store, key, data)
if err != nil && strings.Contains(err.Error(), "previous error") {
// read both errors; usually credentials or endpoint are wrong
} Prevention
- Verify access/secret keys against the exact endpoint before formatting
- Test endpoint connectivity with curl or provider CLI
- Avoid proxies that intercept TLS to the object store
- Confirm the backend supports bucket-creation semantics if relying on auto-create
When it happens
Trigger: Put fails (network error, auth error, DNS failure) and store.Create also fails — e.g. invalid access keys rejected on both calls, unreachable endpoint, or a backend where Create is unsupported and returns its own error.
Common situations: Wrong access/secret keys; endpoint typo causing connection failures; self-signed cert issues against an S3-compatible store; firewall blocking the endpoint.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- (max tries) upload block %s: %s (after %d tries)
- get %s: %s
- Failed to put: %s
- Failed to create bucket %s: %s, previous error: %s Please cr
- Failed to get: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/c3973fa5204b3efa.
Report an issue: GitHub.