Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Laraveldeep's avatar

Missing required client configuration options: region While Trying to Implement S3

Hi,

I am trying to test my file upload sent to s3. I have already installed the package league/flysystem-aws-s3-v3 ~1.0

In my .env file I have set the credentials needed by config/filesystems.php like this:

AWS_KEY=my_key
AWS_SECRET=my_secret
AWS_REGION=us-east-1
AWS_BUCKET=my_bucket

However when I try to store the uploaded file, it is giving me this Error

File: 

vendor\aws\aws-sdk-php\src\ClientResolver.php


Message:

Missing required client configuration options: region: (string) A "region" configuration value is required for the "s3" service (e.g., "us-west-2"). A list of available public regions and endpoints can be found at http://docs.aws.amazon.com/general/latest/gr/rande.html.

I have no idea why it is throwing error and what to look for.

0 likes
14 replies
Laraveldeep's avatar

Thanks @Robstar

Just to test, I have tried playing with various region. However it has no effect. The error remains the same.

Seems like whatever I set on filesystem.php or .env the region variable is not propagated properly back to the driver. Well... not sure

Also the changes you have mentioned must be just recent ones.

I have a fresh installation of 5.5 from past release with these

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

Have tested it using the new keys but error still remains same.

I guess variable name changes in this regard doesn't matter. Whatever is in filesystem.php, if we have it on .env it won't be a problem.

Any other clue?

By the way I am using request method to store the file if it is relevant to the issue

$path = $request->file('uploadedfile')->store('s3_path', 's3');
Laraveldeep's avatar

Can somebody point me to right direction? I am not sure what's wrong with my current config.

robrogers3's avatar

what does this say: config('filesystems.disks.s3');

1 like
Laraveldeep's avatar

@robrogers3

It gives me

[
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
]

region is there. Not sure where is the fault. These are set from my environment file. I have tried also adding the settings on config/filesystems.php but still getting same message.

gregrobson's avatar

Can you echo out the contents of config('filesystems.disks.s3') so it is possible to check that the right env() values are being inserted. (Feel free to censor anything confidential.)

I think @robrogers3 is thinking that it's best to confirm the config has loaded correctly before looking elsewhere at what the problem might be.

1 like
Laraveldeep's avatar

I just upgraded Laravel from 5.5.14 to 5.5.20 with composer update just in case. Now I am getting null for everything from config.

Getting same error while tinkering

Storage::disk('s3')->files()

Weird

Laraveldeep's avatar

@gregrobson

After update I got null for everything... really weird

>>> config('filesystems.disks.s3')
=> [
     "driver" => "s3",
     "key" => null,
     "secret" => null,
     "region" => null,
     "bucket" => null,
   ]
>>>

But this is what I have in my filesystems.php

        's3' => [
            'driver' => 's3',
            'key' => env('my_key'),
            'secret' => env('mysecret'),
            'region' => env('us-east-1'),
            'bucket' => env('my_buket_name'),
        ],
gregrobson's avatar

Ah okay.

// Your config (/config/filesystems.php) should contain
's3' => [
    'driver' => 's3',
    'key' => env('AWS_KEY'),
    'secret' => env('AWS_SECRET'),
    'region' => env('AWS_REGION'),
    'bucket' => env('AWS_BUCKET'),
],

// the environment file (/.env) should contain soemthing like this.
AWS_KEY=MadeThisUp_advbasre2423fsdfsaf
AWS_SECRET=MadeThisUp_afh23oir3urfjj43r34r34rt34f
AWS_REGION=us-east-1
AWS_BUCKET=my.bucket.name

Before testing any changes run php artisan config:clearjust in case you have any cached config values. You haven't mentioned anything about caching previously, but it's best to rule that out as well.

Laraveldeep's avatar

That's what I did initially (set those on .env). After that I hard coded that on filesystems.php.

On both cases I am getting same error that region parameter is not set or missing.

cache is cleared too... Now I am getting null for everything like mentioned before.

Any other clue?

Laraveldeep's avatar
Laraveldeep
OP
Best Answer
Level 7

Well after upgrade and restarting tinker I am getting the correct setting and region issue is resolved.

1 like
gregrobson's avatar

I haven't used tinker - but I believe it doesn't reload config/env environment variables on demand. That might be why you weren't seeing changes?

Incidentally - there's a package that will allow you to reload your session/state when using tinker. https://laravel-news.com/laravel-tinx

1 like
3scube's avatar

I know this thread is closed but I've recently had this problem and wanted to share my solution.

I was encountering this problem upon deployment, but I couldn't replicate it locally:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
   InvalidArgumentException  : Missing required client configuration options: 
region: (string)
  A "region" configuration value is required for the "s3" service
  (e.g., "us-west-2"). A list of available public regions and endpoints can be
  found at http://docs.aws.amazon.com/general/latest/gr/rande.html.

I tried clearing various caches but nothing seemed to work. I was banging my head against a brick wall for hours!

The source of the problem is that in my deployment script I was running composer install before I had created a .env file.

You may wonder why the .env file would ever be missing; I use Capistrano style deployments where a separate release directory is created each time I deploy. The codebase is then cloned into this directory and the dependencies are installed, and so on.

At the bottom of the composer.json file there's a call to @php artisan package:discover --ansi. This command looks at all your service providers and does some Laravel magic.

Some of my custom service providers relied on variables in the .env file. As mentioned before I was running composer install before I had created a .env file. This means the service providers couldn't operate correctly as the variables they relied on didn't exist yet.

I changed my deployment script so that the first thing that happens is the .env file being created and everything works again!

I hope this helps someone in the Laravel community. <3

3 likes

Please or to participate in this conversation.