Question

Problem with Digital Ocean and spaces cannot be accessed

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 ?


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
October 16, 2024

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.