How to fix RequestTimeTooSkewed S3/DO Spaces error?

I am getting this error sometimes from Digital Ocean Spaces, making Put File and Delete File server actions fail:

1. {status: "500", code: "RequestTimeTooSkewed",…}

  1. code: "RequestTimeTooSkewed"
  2. message: {message: null, code: "RequestTimeTooSkewed", region: null, time: "2021-04-16T04:47:17.708Z",…}

    1. code: "RequestTimeTooSkewed"
    2. message: null
    3. region: null
    4. requestId: "tx00000000000001e8cbe36-00607d774a-4ab1230-ams3c"
    5. retryDelay: 8.4801999855181
    6. retryable: false
    7. statusCode: 403
    8. time: "2021-04-16T04:47:17.708Z"

  3. stack: "RequestTimeTooSkewed: null↵ at Request.extractError (/opt/node_app/node_modules/aws-sdk/lib/services/s3.js:700:35)↵ at Request.callListeners (/opt/node_app/node_modules/aws-sdk/lib/sequential_executor.js:106:20)↵ at Request.emit (/opt/node_app/node_modules/aws-sdk/lib/sequential_executor.js:78:10)↵ at Request.emit (/opt/node_app/node_modules/aws-sdk/lib/request.js:688:14)↵ at Request.transition (/opt/node_app/node_modules/aws-sdk/lib/request.js:22:10)↵ at AcceptorStateMachine.runTo (/opt/node_app/node_modules/aws-sdk/lib/state_machine.js:14:12)↵ at /opt/node_app/node_modules/aws-sdk/lib/state_machine.js:26:10↵ at Request.<anonymous> (/opt/node_app/node_modules/aws-sdk/lib/request.js:38:9)↵ at Request.<anonymous> (/opt/node_app/node_modules/aws-sdk/lib/request.js:690:12)↵ at Request.callListeners (/opt/node_app/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
  4. status: "500"

I know the error is caused by a time difference between the requesting server/droplet and the Spaces droplet, but can’t find a way to prevent this from arising once in a while.

Thanks for any help.

EDIT: I found out the error is only thrown on localhost which is a local Docker environment in this case. So I suppose the clue lies in changing the Docker engine time or something like that?

It’s just that you have time difference in your clocks. Between local and remote.

See also

Thanks for the reply @George. The reason for the error was clear to me already, but I was looking for a way to change the Docket container’s time to match it with the S3/Spaces time. This appeared to be unnecessary effort afterwards, because restart of Docker and system solved the issue as well.
Thanks for your response anyways!