Unable to mount R2 bucket using S3FS

I am trying to mount a R2 bucket using S3FS. Similar command works for AWS S3, but it does not work for R2. Using the command below for R2, I get a timeout error saying “Software caused connection abort”.

This command works for AWS S3:

s3fs -o passwd_file={Path to S3 password file},url=https://s3.amazonaws.com {S3 Bucket Name} {Mount Path}

This similar command does not work for R2:

s3fs -o passwd_file={Path to R2 password file},url=https://{R2 Account ID}.r2.cloudflarestorage.com {R2 Bucket Name} {Mount Path}

The password file has a format of {R2 access key id}:{R2 secret access key}

R2 should be S3 compatible, so I don’t know why I cannot mount R2 using S3FS.

Tried with -o use_path_request_style? And use -o endpoint=auto

s3fs -o passwd_file={Path to R2 password file} -o url=$url -o use_path_request_style -o endpoint=auto $bucketname /home/s3mount

df /home/s3mount
Filesystem             1K-blocks  Used         Available Use% Mounted on
s3fs           18014398509465600     0 18014398509465600   0% /home/s3mount

test.txt copy to mounted R2 bucket

cp test.txt /home/s3mount/

# check with aws cli
aws s3 ls --profile r2 --endpoint-url=$url s3://$bucketname/
2022-05-15 07:41:45          2 test.txt

# check with s5cmd
export AWS_PROFILE=r2

# list
s5cmd --endpoint-url=$url ls s3://$bucketname
2022/05/15 08:10:52                 3 test.txt

# contents of test.txt
s5cmd --endpoint-url=$url cat s3://$bucketname/test.txt
1 Like

Thanks. I will give it a try. But AWS will eventually deprecate the path-style URLs. Why is R2 not adopting the virtual hosted-style instead?


You’d have to ask Cloudflare that. Just know right now path style is the one working :slight_smile:

A rather odd design choice for a new service that advertised itself as fully S3 compatible. Hopefully some Cloudflare experts can shed some light here.

1 Like

It appears something changed. The virtual hosted-style seems to be working. :thinking:

1 Like

Virtual-host paths were added on the 16th.

1 Like