Error complaining file .ocdata is missing, but the file is there

Nextcloud version: 24.0.1
Operating system and version_: ubuntu 20.04
nginx
PHP version: 7.4

I am trying to migrate the data folder to an external drive. Right now the data folder is in /var/www/nextcloud/data however I want to put it /external_disk/nextcloud/data where the external ssd is mounted.

I copied the files from /var/www/nextcloud/data to /external_disk/nextcloud/data, put the owner as www-data and changed the datadirectory in /var/www/nextcloud/config/config.php to the new location but the following error Your data directory is invalid. Ensure there is a file called ".ocdata" in the root of the data directory. appears complaining that does not have the .ocdata file, but the file is there.

The /external_disk/nextcloud/data is like this:

root@ubuntu:/external_disk/nextcloud# pwd
/external_disk/nextcloud
root@ubuntu:/external_disk/nextcloud# ls -al
total 12
drwxrwx--- 3 root     root     4096 Jan 25 23:58 .
drwx------ 4 root     root     4096 Jan 25 23:27 ..
drwxr-x--- 6 www-data www-data 4096 Jun  9 20:28 data
root@ubuntu:/external_disk/nextcloud# cd data/
root@ubuntu:/external_disk/nextcloud/data# ls -al
total 412
drwxr-x--- 6 www-data www-data   4096 Jun  9 20:28 .
drwxrwx--- 3 root     root       4096 Jan 25 23:58 ..
-rw-r--r-- 1 www-data www-data    542 Jun  9 20:27 .htaccess
-rw-r--r-- 1 www-data www-data      0 Jun  9 20:27 .ocdata
drwxr-xr-x 7 www-data www-data   4096 Jan 21 16:50 admin
drwxr-xr-x 9 www-data www-data   4096 Dec 28 23:31 appdata_ocbdwpdjsabu
drwxr-xr-x 2 www-data www-data   4096 Jun  9 20:28 files_external
-rw-r--r-- 1 www-data www-data      0 Jun  9 20:27 index.html
-rw-r----- 1 www-data www-data 351060 Jun  9 21:05 nextcloud.log
drwxr-xr-x 4 www-data www-data   4096 Jun  9 20:28 updater-ocbdwpdjsabu
-rw-r--r-- 1 www-data www-data  38562 Jun  9 20:27 updater.log

Everything seems to have the right permissions but I am not bale to get rid of the error Your data directory is invalid. Ensure there is a file called ".ocdata" in the root of the data directory.

Any suggestions to troubleshoot this problem?