Skip to content

S3 HEAD bucket failed: 404 Not Found - CC Switch

Quick fix

If the endpoint contains the bucket name, remove the bucket field from the config to prevent path duplication.

Error output
S3 HEAD bucket 失败: 404 Not Found
(https://mybucket.oss-cn-zhongwei.aliyuncs.com/mybucket/)
English translation

S3 HEAD bucket failed: 404 Not Found (https://mybucket.oss-cn-zhongwei.aliyuncs.com/mybucket/)

When using S3-compatible storage (such as Alibaba Cloud OSS or Cloudflare R2) with a virtual-hosted style endpoint (where the host part includes the bucket name, e.g., `https://mybucket.oss-cn-zhongwei.aliyuncs.com`), cc-switch v3.18.0 has a URL construction logic flaw.

The `is_aws_endpoint` function only recognizes `amazonaws.com`, causing non-AWS endpoints to be incorrectly classified into the path-style branch. In path-style mode, the program forcibly appends the bucket name to the URL path. Since the user's endpoint already contains the bucket name, this results in path duplication (e.g., `/mybucket/`), causing HEAD requests to return 404 Not Found. Additionally, upload operations will store objects under incorrect prefixes.

  1. Open the cc-switch sync settings interface and locate the S3/OSS storage configuration area.

  2. Check the Endpoint address. If the Endpoint is in the format https://<bucket>.oss-cn-<region>.aliyuncs.com, leave the 'Bucket' or 'Bucket Name' configuration item empty or delete its content.

    在 UI 配置中:
    # Endpoint: https://mybucket.oss-cn-zhongwei.aliyuncs.com (保持不变)
    # Bucket: [留空]
  3. Save the configuration and retest the connection. The URL should now correctly resolve without duplicate bucket names, and HEAD requests should succeed.

ToolClaude Code
Version3.18.0
PlatformsLinux
Why do I need to delete the bucket from the config if it's already in my Endpoint?
Because this version of the code cannot automatically recognize non-AWS virtual-hosted style endpoints. If you do not remove the bucket field from the configuration, the program will append the bucket name again in the URL path, resulting in a 404 error.
I have already uploaded files. Can I read them after fixing this?
It may not be possible to read them directly. Due to the previous bug, files might have been stored under an incorrect nested prefix (e.g., `mybucket/cc-switch-sync/v2/...`). You need to manually check the storage console and move files to the correct root directory, or accept that data is scattered in incorrect paths.
Does this bug only affect Alibaba Cloud OSS?
No. Any S3-compatible service using virtual-hosted style endpoints that are not recognized by `is_aws_endpoint` will be affected, including Cloudflare R2, Backblaze B2, etc.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.