Can't connect external storage Service unavailable error 503

Nextcloud version (eg, 29.0.5): 29.0.4.1
Operating system and version (eg, Ubuntu 24.04): raspbian (Debian 12 - Bookworm)
Apache or nginx version (eg, Apache 2.4.25): nginx 1.27.0
PHP version (eg, 8.3): 8.2.22

The issue you are facing:
Can’t connect external storage. I’ve installed nextcloud following these steps:

In the compose.yml file I’ve changed the volumes directory from his directory to a personal directory at ~/nextcloud/extstor where I also mounted my external storage. This directory has full permissions for both root and www-data.

Everything configured just fine until I add the external storage as this nextcloud guide from the GUI. What happens is that the directory shows up in the nextcloud files at the web GUI but I’am unable to add anything there and the directory does not get downloaded when I sync with my devices. It returns service unavailable error 503.

The command to check the mounting directory permissions output:

drwxrwx--- 3 www-data www-data  4096 Aug 14 10:26 .
drwxr-xr-x 4 ace      ace       4096 Aug 19 17:13 ..
drwxrwx--- 2 www-data www-data 16384 Aug 14 10:26 lost+found

Also in spite of what it says in the config.php file there is no ‘/var/www/html/’ or ‘/etc/nginx’ directory in my system.

Is this the first time you’ve seen this error? (Y/N): yes, total noob here :slight_smile:

Steps to replicate it:

  1. Set up nextcloud within a docker container in a raspberry pi 4b like this
  2. Add external storage like this
  3. Try to download it to a device or paste any file to it.

The output of your Nextcloud log in Admin > Logging:
Currently out of my home nextwork and can’t access my dashboard or Nextcloud log in

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'cache',
    'password' => '',
    'port' => 6379,
  ),
  'upgrade.disable-web' => true,
  'instanceid' => 'ocrc59h1w8m3',
  'passwordsalt' => 'V1bTvMaiiKqaona0zahwIqresekGo6',
  'secret' => 'H2yODzf7ye72nk4c4WzqoxXwhnenJtfd/UKKg3p1D9Am8xgi',
  'trusted_domains' => 
  array (
    0 => '192.168.1.232:8443',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '29.0.4.1',
  'overwrite.cli.url' => 'https://192.168.1.232:8443',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_ace',
  'dbpassword' => '0lY4Q5Nr9Xg4Ulygj5ac5dEIO3WOAf',
  'installed' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

PASTE HERE

FYI: It would be easier to help if you posted your actual Compose file.

So you’ve placed the external storage source within your Nextcloud installation folder? I would not do that. At best it will break updates and, worse, with the Docker image - it will get deleted automatically. See Custom Volumes here: GitHub - nextcloud/docker: ⛴ Docker image of Nextcloud

That said, the source for the mount in the GUI will need to be something like /var/www/html/<whatever_you_named_the_source_folder> based on how you’ve described setting up your Docker environment.

If you used the path on your underlying host (i.e. outside of Docker), that might be part of your problem since the container does not have access to that path.

Also in spite of what it says in the config.php file there is no ‘/var/www/html/’ or ‘/etc/nginx’ directory in my system.

There is from the container’s perspective. Keep in mind you’re using Docker.

Everything configured just fine until I add the external storage as this nextcloud guide from the GUI.

The link doesn’t work for the guide you followed.

Currently out of my home nextwork and can’t access my dashboard or Nextcloud log in

That’s fine, but you’ll likely need your logs to debug.

1 Like

Hi, I was able to get the log file and this is my last entry:

{"reqId":"lxfdxA9bt3xgyRXSlA9j","level":3,"time":"2024-08-21T14:25:13+00:00","remoteAddr":"IPadress","user":"ace","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/ace/Armazenamento","message":"opendir(/extdata/): Failed to open directory: Permission denied at /var/www/html/lib/private/Files/Storage/Local.php#164","userAgent":"Mozilla/5.0 (Linux) mirall/3.4.2-1ubuntu1 (Nextcloud, ubuntu-6.8.0-40-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"29.0.4.1","data":{"app":"PHP"}}
{"reqId":"lxfdxA9bt3xgyRXSlA9j","level":3,"time":"2024-08-21T14:25:13+00:00","remoteAddr":"IPadress","user":"ace","app":"webdav","method":"PROPFIND","url":"/remote.php/dav/files/ace/Armazenamento","message":"Directory listing failed","userAgent":"Mozilla/5.0 (Linux) mirall/3.4.2-1ubuntu1 (Nextcloud, ubuntu-6.8.0-40-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"29.0.4.1","exception":{"Exception":"Sabre\\DAV\\Exception\\ServiceUnavailable","Message":"Directory listing failed","Code":0,"Trace":[{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php","line":95,"function":"getChild","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["Armazenamento"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":971,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->","args":["files/ace/Armazenamento"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":1662,"function":"getPropertiesIteratorForPath","class":"Sabre\\DAV\\Server","type":"->","args":["files/ace/Armazenamento",["{DAV:}resourcetype","{DAV:}getlastmodified","{DAV:}getcontentlength","{DAV:}getetag","{http://owncloud.org/ns}size","And 7 more entries, set log level to debug to see all entries"],1]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":1647,"function":"writeMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[["Sabre\\Xml\\Writer",[],"/remote.php/dav/",["d","s","oc","nc"],[]],["Generator"],false]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":346,"function":"generateMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[["Generator"],false]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPropFind","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PROPFIND",[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":383,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":172,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php","Line":217,"message":"Directory listing failed","exception":{},"CustomMessage":"Directory listing failed"}}
``

Hey, thank your for your reply the compose.yml file is as follows:

version: '3'

services:
  db:
    image: postgres:alpine
    restart: always
    volumes:
      - db:/var/lib/postgresql/data:Z
    env_file:
      - db.env
    environment:
      - PUID=109
      - PGID=65534
    networks:
      - proxy-tier


  cache:
    image: redis:6.2-alpine
    restart: always
    ports:
      - '6379:6379'
    command: redis-server --save 20 1
    volumes:
      - cache:/data
    networks:
      - proxy-tier


  app:
    #image: nextcloud:fpm-alpine
    build:
      context: .
      dockerfile: Dockerfile.app
    container_name: nextcloud
    restart: always
    volumes:
      - nextcloud:/var/www/html:z
      - /home/ace/nextcloud/extstor:/extdata
      - php-fpm:/usr/local/etc
      - type: tmpfs
        target: /tmp:exec
    environment:
      - POSTGRES_HOST=db
      - REDIS_HOST=cache
      - PHP_MEMORY_LIMIT=2048M
    env_file:
      - db.env
    depends_on:
      - db
      - cache
    devices:
      - /dev/video10:/dev/video10
      - /dev/video11:/dev/video11
      - /dev/video12:/dev/video12
    networks:
      - proxy-tier


  cron:
    #image: nextcloud:fpm-alpine
    build:
      context: .
      dockerfile: Dockerfile.cron
    restart: always
    volumes:
      - nextcloud:/var/www/html:z
      - /home/ace/nextcloud/extstor:/extdata
      - php-fpm:/usr/local/etc
      - type: tmpfs
        target: /tmp:exec
    entrypoint: /cron.sh
    depends_on:
      - db
      - cache
    devices:
      - /dev/video10:/dev/video10
      - /dev/video11:/dev/video11
      - /dev/video12:/dev/video12
    environment:
      - PHP_MEMORY_LIMIT=2048M
    networks:
      - proxy-tier

  imaginary:
    image: ghcr.io/italypaleale/imaginary:master
    container_name: imaginary
    restart: always
    ports:
      - '9000:9000'
    command: -enable-url-source

  nginx-proxy:
    image: nginx:alpine
    container_name: nginx-proxy
    ports:
      - "8443:443"
    volumes:
      - sslcerts:/etc/nginx/ssl
      - /home/ace/nextcloud/nginx.conf:/etc/nginx/nginx.conf
      - nextcloud:/var/www/html:z,ro
    networks:
      - proxy-tier
    depends_on:
      - app


volumes:
  db:
  php-fpm:
  nextcloud:
  sslcerts:
  cache:
    driver: local

networks:
  proxy-tier:

In the GUI I went to the Admin>Logging but it is just a blank page, something must be wrong right? Is there other way I can access my logs?

The above suggests that a permissions matter. Can you check the permissions from inside of the container of /extdata? e.g.

docker compose exec -u33 app ls -ld /extdata

And maybe confirm you can write to it from within the container:

docker compose exec -u33 app touch /extdata/foo.bar

In the GUI I went to the Admin>Logging but it is just a blank page, something must be wrong right? Is there other way I can access my logs?

This is usually an out-of-date web server configuration matter, such as if you upgraded to >=NC28 without using the latest Nginx config from the Nextcloud Server Admin Manual . It can also sometimes be a browser ad blocker. Do you have any warnings or errors about .mjs files under Admin settings->Overview?

Hi JTR, since starting the topic I made some changes.

  1. I stopped the docker container and moved the disk mount from within the nextcloud directory to /media/nextcloud.
  2. I proceeded to give permissions and ownership to the www-data user to the /media/nextcloud directory
  3. I did get some errors in Admin > Overview the warning about ‘.mjs’ being the most import (I guess as it was in red). There was also another one in yellow that seemed important regarding ‘.well-known’ urls failing on: ‘/.well-known/webfinger’. So I went to my nginx.conf file and changed it to look closer to this one (Nextcloud in webroot configuration).

So yesterday after having made those changes I solved the .mjs error but not the .well-known one, but that didn’t give me access to the external storage anyway. I tried checking permissions to the /media/nextcloud outside the container and checking permissions to the /extdata inside the container and everything seemed right with www-data having permissions to the /media/nextcloud and u33 having permissions to the /extdata within the container, I even made a .txt test file while inside the container successfully with the file being visible even from the nextcloud web interface. Now, today though I can’t access my nextcloud. The problem is the nginx container which refuses to go up and returns the following:

docker logs de97c106faf9
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/08/22 10:14:10 [warn] 1#1: duplicate extension "js", content type: "text/javascript", previous content type: "application/javascript" in /etc/nginx/nginx.conf:240
nginx: [warn] duplicate extension "js", content type: "text/javascript", previous content type: "application/javascript" in /etc/nginx/nginx.conf:240
2024/08/22 10:14:10 [warn] 1#1: duplicate extension "wasm", content type: "application/wasm", previous content type: "application/wasm" in /etc/nginx/nginx.conf:241
nginx: [warn] duplicate extension "wasm", content type: "application/wasm", previous content type: "application/wasm" in /etc/nginx/nginx.conf:241
2024/08/22 10:14:10 [emerg] 1#1: unknown "asset_immutable" variable
nginx: [emerg] unknown "asset_immutable" variable
``

asset_immutable is one of the variables defined in the Nextcloud Nginx config. Sounds like there is a typo or something still in your local config.