CardDAV sync with MacOS

Nextcloud version: 25.0.12
Operating system and version: (NextCloud is on my webhosting) MacOS Monterey 12.7
Apache or nginx version: nginx 1.25.2
PHP version: 7.4

The issue you are facing:
I set up contacts and I can sync perfectly with my Android phone. I cannot sync with my MacBook.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Add CardDAV account to mac.
  2. I tried adding it from the Address Book and from the System Settings,
  3. I tried with my normal NextCloud password and with a new app password (I didn’t get error messages on my accountname or password)
  4. I tried with the full path in “server” and only the NextCloud-server (which is the only one mac keeps anyway, I think this is the correct way) and add the path from link copied from NextCloud-settings in the “path” field. (…/remote.php/dav/addressbooks/users/Jonathan/contactpersonen/)
  5. I tried that path with and without the calendar name (/contactpersonen) or only the calender folder-name.
  6. I tried deleting all data from ~/Library/Application Support/Address Book
  7. I tried at least ten times, restarting my mac sometimes between.

The output of your Nextcloud log in Admin > Logging:

[dav] Fout: Sabre\VObject\Recur\MaxInstancesExceededException: Recurring events are only allowed to generate 3500 at <<closure>>

 0. .../domains/han-pilate.be/public_html/jonat/wolk/apps/dav/lib/CalDAV/Reminder/ReminderService.php line 286
    Sabre\VObject\Recur\EventIterator->valid()
 1. .../domains/han-pilate.be/public_html/jonat/wolk/apps/dav/lib/CalDAV/Reminder/ReminderService.php line 359
    OCA\DAV\CalDAV\Reminder\ReminderService->onCalendarObjectCreate()
 2. .../domains/han-pilate.be/public_html/jonat/wolk/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php line 139
    OCA\DAV\CalDAV\Reminder\ReminderService->onCalendarObjectEdit()
 3. .../domains/han-pilate.be/public_html/jonat/wolk/lib/private/EventDispatcher/ServiceEventListener.php line 87
    OCA\DAV\Listener\CalendarObjectReminderUpdaterListener->handle()
 4. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke()
 5. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
 6. .../domains/han-pilate.be/public_html/jonat/wolk/lib/private/EventDispatcher/EventDispatcher.php line 88
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
 7. .../domains/han-pilate.be/public_html/jonat/wolk/lib/private/EventDispatcher/EventDispatcher.php line 100
    OC\EventDispatcher\EventDispatcher->dispatch()
 8. .../domains/han-pilate.be/public_html/jonat/wolk/apps/dav/lib/CalDAV/CalDavBackend.php line 1338
    OC\EventDispatcher\EventDispatcher->dispatchTyped()
 9. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/sabre/dav/lib/CalDAV/CalendarObject.php line 103
    OCA\DAV\CalDAV\CalDavBackend->updateCalendarObject("*** sensitive parameters replaced ***")
10. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/sabre/dav/lib/DAV/Server.php line 1137
    Sabre\CalDAV\CalendarObject->put()
11. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 492
    Sabre\DAV\Server->updateFile("*** sensitive parameters replaced ***")
12. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpPut()
13. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/sabre/dav/lib/DAV/Server.php line 472
    Sabre\DAV\Server->emit()
14. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/sabre/dav/lib/DAV/Server.php line 253
    Sabre\DAV\Server->invokeMethod()
15. .../domains/han-pilate.be/public_html/jonat/wolk/3rdparty/sabre/dav/lib/DAV/Server.php line 321
    Sabre\DAV\Server->start()
16. .../domains/han-pilate.be/public_html/jonat/wolk/apps/dav/lib/Server.php line 361
    Sabre\DAV\Server->exec()
17. .../domains/han-pilate.be/public_html/jonat/wolk/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
18. .../domains/han-pilate.be/public_html/jonat/wolk/remote.php line 172
    require_once(".../ ... p")

PUT /wolk/remote.php/dav/calendars/Jonathan/persoonlijk/aa3a417e-0d55-4e2b-aaad-8587ecec09a8.ics
from 212.224.228.48 by Jonathan at 2023-10-09T14:24:24+00:00

The output of your config.php file in

<?php
$CONFIG = array (
  'instanceid' => 
  'passwordsalt' => 
  'secret' => 
  'trusted_domains' => 
  array (
    0 => 'jonat.han-pilate.be',
    1 => '',
  ),
  'datadirectory' => '/home/.../domains/han-pilate.be/public_html/jonat/wolk/data',
  'dbtype' => 'mysql',
  'version' => '25.0.12.0',
  'default_phone_region' => 'BE',
  'default_locale' => 'nl_BE',
  'overwrite.cli.url' => 'https://jonat.han-pilate.be/wolk',
  'dbname' => '...',
  'dbhost' => 'localhost:...',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '...',
  'dbpassword' => '...',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '...',
  'mail_domain' => '...',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '...',
  'mail_smtpport' => '...',
  'mail_smtpname' => '...',
  'mail_smtppassword' => '...',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'app_install_overwrite' => 
  array (
    0 => 'ocjobs',
    1 => 'files_markdown',
  ),
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpsecure' => 'ssl',
);

The output of webhosting logs (part that seems relevant):

[11/Oct/2023:15:25:28 +0200] “PROPFIND /.well-known/carddav HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:25:28 +0200] “PROPFIND / HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:25:28 +0200] “PROPFIND /principals/ HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:25:50 +0200] “PROPFIND /.well-known/carddav HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:25:50 +0200] “PROPFIND / HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:25:50 +0200] “PROPFIND /principals/ HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:26:49 +0200] “PROPFIND /.well-known/carddav HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:26:49 +0200] “PROPFIND / HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”
[11/Oct/2023:15:26:49 +0200] “PROPFIND /principals/ HTTP/1.0” 405 964 “-” “macOS/12.7 (21G816) AddressBookCore/2498.5.1”

I don’t have a solution yet, but I think I found the problem. My NextCloud is not in the root folder.
In the administration panel, I get this error:

* Je webserver is niet goed ingesteld om "/.well-known/webfinger" te vinden. Meer informatie is te vinden in onze [documentatie↗](https://docs.nextcloud.com/server/25/go.php?to=admin-setup-well-known-URL).
* Je webserver is niet goed ingesteld om "/.well-known/nodeinfo" te vinden. Meer informatie is te vinden in onze [documentatie↗](https://docs.nextcloud.com/server/25/go.php?to=admin-setup-well-known-URL).
* Je webserver is niet goed ingesteld om "/.well-known/caldav" te vinden. Meer informatie is te vinden in onze [documentatie↗](https://docs.nextcloud.com/server/25/go.php?to=admin-setup-well-known-URL).
* Je webserver is niet goed ingesteld om "/.well-known/carddav" te vinden. Meer informatie is te vinden in onze [documentatie↗](https://docs.nextcloud.com/server/25/go.php?to=admin-setup-well-known-URL).

Which directs to this documentation:

Service discovery

Some clients - especially on iOS/macOS - have problems finding the proper sync URL, even when explicitly configured to use it.

If you want to use CalDAV or CardDAV clients or other clients that require service discovery together with Nextcloud it is important to have a correct working setup of the following URLs:

https://example.com/.well-known/carddav

https://example.com/.well-known/caldav

Those need to be redirecting your clients to the correct endpoints. If Nextcloud is running at the document root of your Web server the correct URL is https://example.com/remote.php/dav for CardDAV and CalDAV and if running in a subfolder like nextcloud, then https://example.com/nextcloud/remote.php/dav.

For the first case the .htaccess file shipped with Nextcloud should do this work for you when you’re running Apache. You need to make sure that your Web server is using this file. Additionally, you need the mod_rewrite Apache module installed to process these redirects. When running Nginx please refer to NGINX configuration.

If your Nextcloud instance is installed in a subfolder called nextcloud and you’re running Apache create or edit the .htaccess file within the document root of your Web server and add the following lines:

You have to add 301-redirects for /.well-known/caldav and /.well-known/carddav to point to /wolk/remote.php/dav.

If you have access to the nginx configuration of the webserver, use the one from the documentation for nextcloud in a subdir of webroot: https://docs.nextcloud.com/server/25/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-the-nginx-webroot

If you do not hava access to the nginx configuration, you have to ask your webhoster to add those 301-redirects.