Report this

What is the reason for this report?

Problem with Digital Ocean and spaces cannot be accessed

Posted on October 16, 2024
enr9

By enr9

Hello,

I’ve a problem using Digital Ocean and spaces on Laravel 10. I filled my .env like this:


 DO_SPACES_KEY=*************

DO_SPACES_SECRET=********************

DO_SPACES_ENDPOINT=fra1.digitaloceanspaces.com

DO_SPACES_REGION=FRA1

DO_SPACES_BUCKET=****************

All the keys are working because my colleagues are using the same as me, and we even tried to generate new one.

My config/filesystems.php :

 'spaces' => [

            'driver' => 's3',

            'key' => env('DO_SPACES_KEY'),

            'secret' => env('DO_SPACES_SECRET'),

            'endpoint' => env('DO_SPACES_ENDPOINT'),

            'region' => env('DO_SPACES_REGION'),

            'bucket' => env('DO_SPACES_BUCKET'),

        ],

I got this error:

Disk named spaces cannot be accessed

Do you have an idea how can I fix it please ?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey @enr9! 👋

The error "Disk named spaces cannot be accessed" could be caused by a couple of different issues.

Your config/filesystems.php configuration looks good, but make sure that the 'spaces' disk is set as the default or explicitly used in your code. Check your config/filesystems.php file for the default disk setting:

'default' => env('FILESYSTEM_DISK', 'spaces'),

If you’re not using 'spaces' as the default, make sure you are specifying the 'spaces' disk when working with files in your code:

Storage::disk('spaces')->put('file.txt', 'Contents');

On another note, double-check your bucket name in your .env file:

DO_SPACES_BUCKET=your-bucket-name

It should exactly match the name of your Spaces bucket in DigitalOcean. Sometimes, small typos or extra spaces can cause issues.

For DO_SPACES_ENDPOINT, it’s best to use the HTTPS endpoint to ensure secure connections:

DO_SPACES_ENDPOINT=https://fra1.digitaloceanspaces.com

If you don’t have the https:// prefix it might cause weird problems.

Also sometimes, changes to the .env file or configuration files might not take effect due to caching. Clear your configuration cache using:

php artisan config:clear

Let me know if the problem persists!

- Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.