{"record":{"id":"139039b051bae6c8","repo":"benbjohnson/litestream","slug":"s3-cannot-lookup-bucket-region-w","errorCode":null,"errorMessage":"s3: cannot lookup bucket region: %w","messagePattern":"s3: cannot lookup bucket region: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"s3/replica_client.go","lineNumber":377,"sourceCode":"\n\t// Validate required configuration\n\tif c.Bucket == \"\" {\n\t\treturn fmt.Errorf(\"s3: bucket name is required\")\n\t}\n\n\t// Validate SSE configuration\n\tif err := c.validateSSEConfig(); err != nil {\n\t\treturn err\n\t}\n\n\t// Look up region if not specified and no endpoint is used.\n\t// Endpoints are typically used for non-S3 object stores and do not\n\t// necessarily require a region.\n\tregion := c.Region\n\tif region == \"\" {\n\t\tif c.Endpoint == \"\" {\n\t\t\tif region, err = c.findBucketRegion(ctx, c.Bucket); err != nil {\n\t\t\t\treturn fmt.Errorf(\"s3: cannot lookup bucket region: %w\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tregion = DefaultRegion // default for non-S3 object stores\n\t\t}\n\t}\n\n\t// Create HTTP client with 24 hour timeout for long-running operations\n\thttpClient := &http.Client{\n\t\tTimeout: 24 * time.Hour,\n\t}\n\n\t// Always configure custom HTTP Transport with controlled keepalive settings\n\t// to reduce idle CPU usage from default transport's aggressive keepalives.\n\t// See: https://github.com/benbjohnson/litestream/issues/992\n\thttpClient.Transport = &http.Transport{\n\t\tProxy: http.ProxyFromEnvironment,\n\t\tDialContext: (&net.Dialer{\n\t\t\tTimeout:   30 * time.Second,","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/s3/replica_client.go#L359-L395","documentation":"Thrown during S3 replica client initialization when no Region and no Endpoint were configured, forcing an automatic bucket-region lookup against AWS (findBucketRegion). The lookup call itself failed — typically due to network/DNS failure, missing or invalid AWS credentials, a nonexistent bucket, or an STS/head-bucket denial — so the client cannot determine which regional endpoint to use. The underlying error is wrapped and identifies the exact cause.","triggerScenarios":"Thrown at s3/replica_client.go:377 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the region explicitly in the replica configuration (region: us-east-1) to skip the automatic lookup","If using a non-AWS S3-compatible store (MinIO, GCS, etc.), set endpoint so DefaultRegion is used instead of a lookup","Verify AWS credentials are present and valid (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or IAM role)","Check network connectivity and DNS resolution to s3.amazonaws.com","Confirm the bucket exists and the account is authorized to access it"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}