S3 Copy Illegal Location Constraint Exception Error When Trying to Copy to a New Path

What is the problem you are having with rclone?

I am trying to copy a file in rclone to a different existing bucket but to a not existing path. Here rclone is actually crashing with the following error:

NOTICE: Failed to copy: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: DC32VRCBK2Q7FRGC, HostID: QE+9xKEcU3bE765d8IgWN0lLFRA0u0mtfXdAKS7MbBb+eUXE/Wyn9oFAxArUNkawpoqLNPifAis=, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

When I use an existing file path, the command executes successfully. Similarly, re-running the same command with AWS CLI v2 also works without issues. Additionally, including the --s3-no-check-bucket flag the file copy succeeds. However, if I omit this flag, the command fails. It’s worth noting that the credentials being used belong to a user with wildcard S3 permissions, including the s3:CreateBucket permission. The region and the access/secret keys are set as env variables. The region is set to eu-central-1 using the following command: export RCLONE_CONFIG_AWS_REGION=eu-central-1.

Run the command 'rclone version' and share the full output of the command.

rclone v1.68.2
- os/version: arch (64 bit)
- os/kernel: 6.12.1-arch1-1 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.23.3
- go/linking: dynamic
- go/tags: none

Yes, latest 1.68.2

Which cloud storage system are you using? (eg Google Drive)

AWS S3

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone copy aws:<source_bucket_name>/<file_path> aws:<dst_bucket_name>/<file_path>

The rclone config contents with secrets removed.

[aws]
type = s3
provider = AWS
env_auth = true
### Double check the config for sensitive info before posting publicly

A log from the command with the -vv flag

2024/12/03 12:10:38 DEBUG : rclone: Version "v1.68.2" starting with parameters ["rclone" "copy" "-vv" "aws:team-****/demo/20s.mp3" "aws:****/tst2/"]
2024/12/03 12:10:38 DEBUG : Creating backend with remote "aws:team-****/demo/20s.mp3"
2024/12/03 12:10:38 DEBUG : Using config file from "/home/gstoyanov/.config/rclone/rclone.conf"
2024/12/03 12:10:38 DEBUG : Setting type="s3" for "aws" from environment variable RCLONE_CONFIG_AWS_TYPE
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : aws: detected overridden config - adding "{z-krK}" suffix to name
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : fs cache: adding new entry for parent of "aws:team-****/demo/20s.mp3", "aws{z-krK}:team-****/demo"
2024/12/03 12:10:38 DEBUG : Creating backend with remote "aws:****/tst2/"
2024/12/03 12:10:38 DEBUG : Setting type="s3" for "aws" from environment variable RCLONE_CONFIG_AWS_TYPE
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : aws: detected overridden config - adding "{z-krK}" suffix to name
2024/12/03 12:10:38 DEBUG : Setting region="eu-central-1" for "aws" from environment variable RCLONE_CONFIG_AWS_REGION
2024/12/03 12:10:38 DEBUG : fs cache: renaming cache item "aws:*****/tst2/" to be canonical "aws{z-krK}:****/tst2"
2024/12/03 12:10:38 DEBUG : 20s.mp3: Need to transfer - File not found at Destination
2024/12/03 12:10:38 ERROR : 20s.mp3: Failed to copy: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: 29MKW0GQQBMJYBJJ, HostID: +4h/eigqyMYGDEW1AfCA0qMfCbbePmT1L6jXgP1usIblOswxWAq5NSMYNYclkj6msumOAVJ/Wj0/2OEG4hiCFg==, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
2024/12/03 12:10:38 ERROR : Attempt 1/3 failed with 1 errors and: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: 29MKW0GQQBMJYBJJ, HostID: +4h/eigqyMYGDEW1AfCA0qMfCbbePmT1L6jXgP1usIblOswxWAq5NSMYNYclkj6msumOAVJ/Wj0/2OEG4hiCFg==, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
2024/12/03 12:10:39 DEBUG : 20s.mp3: Need to transfer - File not found at Destination
2024/12/03 12:10:39 ERROR : 20s.mp3: Failed to copy: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: 29MW241TFXCRN5T7, HostID: 5zpGZe6gJsNq7ophaRvyK/H4qVdzXE6AH2Xzec3dgNu6uhrIDM9+ejqg0vIpTASckHx6JovvkoI=, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
2024/12/03 12:10:39 ERROR : Attempt 2/3 failed with 1 errors and: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: 29MW241TFXCRN5T7, HostID: 5zpGZe6gJsNq7ophaRvyK/H4qVdzXE6AH2Xzec3dgNu6uhrIDM9+ejqg0vIpTASckHx6JovvkoI=, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
2024/12/03 12:10:39 DEBUG : 20s.mp3: Need to transfer - File not found at Destination
2024/12/03 12:10:39 ERROR : 20s.mp3: Failed to copy: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: 29MW5BPM1HE3FXKR, HostID: gjfdWj1YRuY3r/gGrx3l2UtB/hheJi7HCbxbIpIsxeExyEr15rVbCGQPOye5Q6xjr04ljeAG68ge6PP429G28P9uVX5LrbjTPG8LizZP8uM=, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
2024/12/03 12:10:39 ERROR : Attempt 3/3 failed with 1 errors and: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: 29MW5BPM1HE3FXKR, HostID: gjfdWj1YRuY3r/gGrx3l2UtB/hheJi7HCbxbIpIsxeExyEr15rVbCGQPOye5Q6xjr04ljeAG68ge6PP429G28P9uVX5LrbjTPG8LizZP8uM=, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
2024/12/03 12:10:39 INFO  : 
Transferred:   	         0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         1.0s

2024/12/03 12:10:39 DEBUG : 7 go routines active
2024/12/03 12:10:39 NOTICE: Failed to copy: operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: 29MW5BPM1HE3FXKR, HostID: gjfdWj1YRuY3r/gGrx3l2UtB/hheJi7HCbxbIpIsxeExyEr15rVbCGQPOye5Q6xjr04ljeAG68ge6PP429G28P9uVX5LrbjTPG8LizZP8uM=, api error IllegalLocationConstraintException: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

Please note, that I have redacted the bucket names in the command and that as stated above the same works with the AWS CLI v2 using exactly the same credentials:

aws s3 cp s3://<source_bucket>/demo/20s.mp3 s3://<dst_bucket>/tst2/

welcome to the forum,

specify the location constraint.


to keep the logs small, --retries=1


for a deeper look, --dump=headers

Specifying the location_constraint=eu-central-1 manually in the config file did the trick, but then why do we need to do so? What if we want to transfer files between buckets residing in different regions?

In addition, from your own documentation:

--s3-location-constraint
Location constraint - must be set to match the Region.
Used when creating buckets only.

But in my case, I am not creating a new bucket, just uploading the file to a new path inside an existing bucket, so rclone should not try to create a bucket and not rely on the location_constraint value.

so, i can only assume that the aws cli automatically adds the location restraint, whereas rclone does not.

specify the location for the source and the dest.
there are a few ways to do that.

try something like this

rclone copy aws,location_constraint=eu-central-1:<source_bucket_name>/<file_path> aws,location_constraint=eu-central-2:<dst_bucket_name>/<file_path>`

In rclone documentation is stated that the location_constraint is only required when creating a new bucket and in my case, I am just setting a new path prefix for the file in an existing bucket, so I don't understand why we need to pass this location_constraint.

that does not make sense? if the user has wildcard policy, then would not need that --s3-no-check-bucket ?
can you post that user policy? is there a bucket policy?

recently, rclone switched from AWS SDK v1 to AWS SDK v2, maybe a side effect
might test v1.67.0

recently, rclone switched from AWS SDK v1 to AWS SDK v2, maybe a side effect
might test v1.67.0

I confirm that with v. 1.67.0 it doesn't return any error when copying the file with the same command, so apparently the switch to AWS SDK v2 introduced the bug.

./rclone copy -P aws:<src_bucket>/demo/20s.mp3 aws:<dst_bucket>/tst/

Transferred:   	 110.136 KiB / 110.136 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Server Side Copies:     1 @ 110.136 KiB
Elapsed time:         1.0s

and this is the version of rclone:

rclone v1.67.0
- os/version: arch (64 bit)
- os/kernel: 6.12.1-arch1-1 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.22.4
- go/linking: static
- go/tags: none

The configuration is the same, without the location_constraint line.

can you please open a new issue at github?
in the issue, make a link to this topic.
and then post the link to the githhub issue in this topic.

in the mean time, i shared the workarounds.

done: S3 Copy Illegal Location Constraint Exception Error When Trying to Copy to a New Path · Issue #8230 · rclone/rclone · GitHub