KHAN's avatar
Level 4

Amazon S3 Giving Me Connection Refused

Hi,

Im trying to switch my Storage Disk to amazon S3 to then upload. I've required the package league/flysystem-aws-s3-v3 according to documentation.

FileSystem Config.

  'default' => env('APP_DISK'),

       's3' => [
            'driver' => 's3',
            'key' => env('S3_KEY'),
            'secret' =>  env('S3_SECRET'),
            'region' =>  env('S3_REGION'),
            'bucket' =>  env('S3_BUCKET'),
        ],

Setup my account on amazon s3, created a new user using Identity and Access Management. Given the user a policy of AmazonS3FullAccess copied the generated key and secret values into my env file.

Route::get('s3', function() {
    Storage::put('myfile.txt' , 'Test File');
});

I then try and go on this route to test an upload of a file, but i am getting a connection refused error.

Error executing "ListObjects" on "https://s3.frankfurt.amazonaws.com/bucketname?prefix=myfile.txt%2F&max-keys=1&encoding-type=url"; AWS HTTP error: Error creating resource: [message] fopen(https://s3.frankfurt.amazonaws.com/bucketname?prefix=myfile.txt%2F&max-keys=1&encoding-type=url): failed to open stream: Connection refused
[file] /var/www/ProjectName/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
[line] 312
0 likes
1 reply
KHAN's avatar
KHAN
OP
Best Answer
Level 4

add the correct region from here then it worked

docs.aws.amazon.com/general/latest/gr/rande.html

Please or to participate in this conversation.