No push notifications after moving to a new server

Until a few days ago, I operated my Nextcloud server without any problems on my old vServer. Due to some missing possibilities with that vServer I had to migrate to another one. Before doing so, I read some experience reports about how to install Nextcloud the best way: by “hand” (as before), as snap package or as docker container. I decided for the latter.

Everything seems to be fine with that. I only have some problems:

1.) Calendar synchronisation

Since I also ported my domain to the new vServer, I thought I do not have to change any configuration on our family mobile phones to synchronize calendars and contacts since I only used the domain name and no ip adresses when configuring the phones. I just exported all calendars and contacts by using the Nextcloud GUI and imported them again to the new server (also via the GUI).

But my Android phone is currently not able to synchronize e.g. the calendar (via DAVx5).

When I try to do so, no entries appear in the logfile. Then I tried to uninstall the Nextcloud app on my phone and I got some log output.

<ip> - <user> [02/Dec/2020:10:17:24 +0000] "PROPFIND /remote.php/dav/calendars/<user>/personal/ HTTP/1.1" 207 1970 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - <user> [02/Dec/2020:10:17:25 +0000] "PROPFIND /remote.php/dav/calendars/<user>/gemeinsamer-kalender/ HTTP/1.1" 207 2109 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - <user> [02/Dec/2020:10:17:25 +0000] "PROPFIND /remote.php/dav/addressbooks/users/<user>/gemeinsame-kontakte/ HTTP/1.1" 207 2014 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - <user> [02/Dec/2020:10:17:25 +0000] "REPORT /remote.php/dav/calendars/<user>/personal/ HTTP/1.1" 207 1646 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - <user> [02/Dec/2020:10:17:26 +0000] "PROPFIND /remote.php/dav/calendars/<user>/personal/ HTTP/1.1" 207 2108 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - <user> [02/Dec/2020:10:17:31 +0000] "PROPFIND /remote.php/dav/addressbooks/users/<user>/contacts/ HTTP/1.1" 207 2001 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - - [02/Dec/2020:10:17:32 +0000] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 230 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36"
<ip> - <user> [02/Dec/2020:10:17:32 +0000] "PROPFIND /remote.php/dav/addressbooks/users/<user>/contacts/ HTTP/1.1" 207 2001 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - <user> [02/Dec/2020:10:17:33 +0000] "PROPFIND /remote.php/dav/addressbooks/users/<user>/contacts/ HTTP/1.1" 207 2005 "-" "DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10"
<ip> - - [02/Dec/2020:10:17:41 +0000] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 230 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0"

With that it seems that the calendars are only synchronized partially since they reach my phone but the new entries from my phone are not synchronized to the Nextcloud instance.

There is also an iPhone in the family. Funnily there is one calendar synchronized, but one is not. The logfile says:

<ip> - - [02/Dec/2020:07:57:26 +0000] "OPTIONS /remote.php/dav/principals/users/<user>/ HTTP/1.1" 401 557 "-" "-" 25 "nextcloud@docker" "http://<ip>:80" 63ms
<ip> - - [02/Dec/2020:07:57:26 +0000] "OPTIONS /remote.php/dav/principals/users/<user>/ HTTP/1.1" 200 0 "-" "-" 26 "nextcloud@docker" "http://<ip>:80" 63ms
<ip> - - [02/Dec/2020:07:57:27 +0000] "REPORT /remote.php/dav/principals/users/<user>/ HTTP/1.1" 401 557 "-" "-" 27 "nextcloud@docker" "http://<ip>:80" 70ms
<ip> - - [02/Dec/2020:07:57:27 +0000] "REPORT /remote.php/dav/principals/users/<user>/ HTTP/1.1" 207 554 "-" "-" 28 "nextcloud@docker" "http://<ip>:80" 77ms
<ip> - - [02/Dec/2020:07:57:27 +0000] "PROPFIND</remote.php/dav/calendars/<user>/ HTTP/1.1" 401 557 "-" "-" 29 "nextcloud@docker" "http://<ip>:80" 46ms
<ip> - - [02/Dec/2020:07:57:28 +0000] "PROPFIND /remote.php/dav/calendars/<user>/ HTTP/1.1" 207 1341 "-" "-" 30 "nextcloud@docker" "http://<ip>:80" 82ms
<ip> - - [02/Dec/2020:07:57:28 +0000] "PROPFIND /remote.php/dav/calendars/<user>/inbox/ HTTP/1.1" 207 250 "-" "-" 31 "nextcloud@docker" "http://<ip>:80" 60ms
<ip> - - [02/Dec/2020:07:57:28 +0000] "PROPFIND /remote.php/dav/calendars/<user>/inbox/ HTTP/1.1" 207 250 "-" "-" 32 "nextcloud@docker" "http://<ip>:80" 58ms

as you can see, there are some http-401 codes!

2.) Push notifications

Currently I get no push notifications. I reinstalled the official Android Nextcloud app and it gives a note about new calendar entries in the notifications area, but there it also says that push notifications are currently not avalaible. Somewhere here in the forum I found a post that proposes to test, if push notifications can be triggered manually with the command:

docker exec --user www-data nextcloud-app php occ notification:test-push <user>

but there I get the info No devices found for user. In the “notifications” area in the Android Nextcloud app, these test-notifications are listed.

Do I have to register my phone manually? Do I have to open some ports in my firewall?

Thank you very much in advance for your help to these two issues!!!

If you need more log output, of course I will provide that, if you tell me what you need or what I have to test!

Nextcloud version (eg, 18.0.2): 20.0.2 (as in the latest docker image)
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04 with Docker 19.03.13
Apache or nginx version (eg, Apache 2.4.25): apache (as in the docker image) with traefik (latest) in front
PHP version (eg, 7.1): 7.4.13 (as in the nextcloud docker image)
“com.docker.compose.version”: “1.27.4”

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): Y (old installation was fine regarding that issues)

Steps to replicate it:

a) try to synchronize my phone
b) create calendar entries and wait for notification

The output of your Nextcloud log in Admin > Logging:
see above

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

$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  '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' => 'nextcloud-redis',
    'password' => 'xxx',
    'port' => 6379,
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'nextcloud.<mydomain>.de',
  'trusted_proxies' => '<ip>/16',
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'https://nextcloud.<mydomain>.de',
  'overwriteprotocol' => 'https',
  'overwritehost' => 'nextcloud.<mydomain>.de',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxx',
  'installed' => true,
  'instanceid' => '<id>',
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => '',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpport' => '587',
  'mail_from_address' => '<from>',
  'mail_domain' => '',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '<emailaddress>',
  'mail_smtppassword' => 'xxx',
  'mail_smtpsecure' => 'tls',

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

see above

At least the problem with the strange behaviour while syncing DAV-data, seems not to only affect me but to be a common problem (see:
The same exception log output as in the above mentioned thread can be found on my server while trying to re-recognize calendars:

{"reqId":"<...>","level":0,"time":"2020-12-03T10:18:51+01:00","remoteAddr":"<ip>","user":"--","app":"no app in context","method":"PROPFIND","url":"/remote.php/dav/calendars/<user>/","message":{"Exception":"OC\\Authentication\\Exceptions\\InvalidTokenException","Message":"Token does not exist","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Authentication/Token/Manager.php","line":147,"function":"getToken","class":"OC\\Authentication\\Token\\DefaultTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/User/Session.php","line":532,"function":"getToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/User/Session.php","line":448,"function":"isTokenPassword","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php","line":131,"function":"logClientIn","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php","line":106,"function":"validateUserPass","class":"OCA\\DAV\\Connector\\Sabre\\Auth","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php","line":254,"function":"check","class":"Sabre\\DAV\\Auth\\Backend\\AbstractBasic","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php","line":156,"function":"auth","class":"OCA\\DAV\\Connector\\Sabre\\Auth","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php","line":192,"function":"check","class":"OCA\\DAV\\Connector\\Sabre\\Auth","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php","line":144,"function":"check","class":"Sabre\\DAV\\Auth\\Plugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"beforeMethod","class":"Sabre\\DAV\\Auth\\Plugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":458,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["beforeMethod:PROPFIND",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":332,"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":167,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Authentication/Token/DefaultTokenProvider.php","Line":160,"Previous":{"Exception":"OCP\\AppFramework\\Db\\DoesNotExistException","Message":"token does not exist","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Authentication/Token/DefaultTokenProvider.php","line":158,"function":"getToken","class":"OC\\Authentication\\Token\\DefaultTokenMapper","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/Authentication/Token/Manager.php","line":147,"function":"getToken","class":"OC\\Authentication\\Token\\DefaultTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/User/Session.php","line":532,"function":"getToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/User/Session.php","line":448,"function":"isTokenPassword","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php","line":131,"function":"logClientIn","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php","line":106,"function":"validateUserPass","class":"OCA\\DAV\\Connector\\Sabre\\Auth","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php","line":254,"function":"check","class":"Sabre\\DAV\\Auth\\Backend\\AbstractBasic","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php","line":156,"function":"auth","class":"OCA\\DAV\\Connector\\Sabre\\Auth","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php","line":192,"function":"check","class":"OCA\\DAV\\Connector\\Sabre\\Auth","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php","line":144,"function":"check","class":"Sabre\\DAV\\Auth\\Plugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"beforeMethod","class":"Sabre\\DAV\\Auth\\Plugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":458,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["beforeMethod:PROPFIND",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":332,"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":167,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Authentication/Token/DefaultTokenMapper.php","Line":91},"CustomMessage":"Token is not valid: Token does not exist"},"userAgent":"DAVx5/3.3.7-gplay (2020/11/28; dav4jvm; okhttp/4.9.0) Android/10","version":""}

Did you manage to solve this? I updated with the debug log output.

Unfortunately not - but I didn’t have time to play around either

I’ve got good and bad news …

Yesterday I updated my instance from 20.0.2 to and at least the dav synchronisation is working again. Therefore I’ll try to reduce the headline of thsi thread afterwards.

Unfortunately the problem with the missing push notifications is furthermore there.

I tried some things (that are described in several threads here in the forum all struggling with a similar problem but mostly related to the Talk app) to get it working (2FA, app key, reinstalling the NC app and clearing the cache, and many more) but nothing solves the problem. The notifications app is activated, of course and notifications are activated for most of the events!

The following things are interesting:

  • the affected users (that does not receive notifications) have installed the NC apps (iOS and Android) and signed in to my NC instance
  • The affected users got push notifications before migrating to the new instance (migration from 20.0.2 non-docker to 20.0.5 on docker)
  • notifications are shown on the desktop as popups in the browser
  • private and public key files are existent for the affected users in the nextcloud/data/appdata_ocyc7ob21ogg/identityproof folder (filesystem rights are set correct)
  • Table oc_notifications_pushtokens does not contain any entries (and thus none for the affected users)
  • When I try occ notification:test-push for the affected users I get No devices found for user

Then I found another thread which led me to do the same test with a newly created account and with a new (Android) device. And see: notifications are working fine for that account on the new device. With that, a corresponding entry in table oc_notifications_pushtokens is created.

The question is: how can I get the entries in oc_notifications_pushtokens back for my “old” users to test if afterwards everything works fine with push notifications?

Does anyone have an idea? Thank you very much in advance!!!

How does the interaction with nextclouds push server/proxy work? Could it be, that my devices are furthermore tied to my old server and so any attempt to register them to my new server is senseless?

cc @nickvergessen

Remove the accounts on the mobile devices and log in newly again.

@nickvergessen, thank you for your quick response!!!

I tried that again, but it doesn’t solve my problem. After deleting the account on my mobile phone and logging in again with the official Nextcloud Android app, an attempt to

docker exec --user www-data nextcloud-app php occ notification:test-push

with my username results in No devices found for user and no new entries in oc_notifications_pushtokens are created.

The corresponding log entries of the log in attempt can be found >here.

As you can see, there are some exceptions (like an InvalidTokenException). The used Android app version is 3.14.3.

Do you have any ideas?

Thank you very much in advance for your help!

Best, Nico

Hi @nickvergessen!
Sorry to bother you with this, but do you have an idea, why your approach doesn’t work on my side?
Cheers, Nico

I found an DB dump of my old instance and fetched out the entries in oc_notifications_pushtokens that are missing at my new installation.

If I manually insert them again into the mariaDB database and execute docker exec --user www-data nextcloud-app php occ notification:test-push <user>, the following happens:

  1. InvalidTokenException is thrown
Trying to push to 1 devices
Language is set to de
Private user key size: 1704
Public user key size: 451
Identified 0 Talk devices and 1 others.
Device token:9
InvalidTokenException is thrown

2.) the corresponding entry in oc_notifications_pushtokens is deleted afterwards.

Thank you for posting this occ command. It allowed me to confirm that the issue, which seems to be the same one as yours, is linked to my account. However, I do not want to delete it and set everything up fresh. Did you end up solving this?

Hi @nexthund !
No, unfortunately not. As you can see above, I tried many things but I do not have an idea to fix that and it seems that no one else here have one.
If you will get around this, I would be grateful for a hint on how you solved it.

Ha! Scratch my below message (aside from the greetings to you)! I found a workaround that works for me! My phone (OnePlus 7) supports a work profile, which allows me to install two versions of any app. So I just switched to that, installed Nextcloud with my existing Nextcloud account and voilà, Notifications are working!

Granted, this is not a solution, but a workaround. But as long as your phone supports a work profile and you don’t need it for anything else, this should hopefully also work for you. :smiley:

PREVIOUS MESSAGE (maybe helpful in some way):

Thanks for the quick reply @nicoletto , especially after such a long time!

It’s a bummer though. My secret hope was that you had stopped posting here because you had solved it. :laughing:

I also tried various things. If I add a second account to my Android app, that account works, but the one I need still doesn’t. I tried reinstalling the app via a different Google account on the same phone. Nothing helped.

When moving to another server, if you want all the configurations to keep working as you expect them to, you need to backup and restore the database to the new server in addition to copying the filesystem. Instead it seems to me that what you did is a full new installation and then tried to migrate some of the data over. Unfortunately, this process leaves a lot of data behind.

1 Like

Yes, of course @Larry_Boyd , but I am pretty sure that there must be a way to decouple the account/phone combination from the notificatuon server and reassign it afterwards so that even in cases where it wasn’t possible to recover the backup, it will be possible to get notifications again. But unfortunately nobody seems to know how …

Yes there is a way, you need to sign out the mobile talk application and sign it back in. The push tokens are generated on the server during the initial sign-in process.

The process is described here; notifications/ at master · nextcloud/notifications · GitHub

1 Like

That sounds good! Do you have a hint, how the process looks like with the official Nextcloud app (on Android) respectively DavX ?

Either clear application data and it will prompt you to sign in again next time you start it, or hit the account button → settings → remove account and then proceed to add a new account.

There are no push notifications for DAV. The synchronization for that is handled in a polling manner as implemented by DAVx5. If it isn’t working, then its probably (and certainly SHOULD be) using an application-specific password. Things like 2FA (which I highly recommend) won’t work otherwise.

You should go into the DAVx5 account settings and set a new application password, or remove the account and create it again through the nextcloud (files) application.

Just for context: I have not ever moved server. This is still my first server. So these issues cannot have been caused by that.

@Larry_Boyd I tried all of your suggestions and they did not work. Only my described workaround with a separate Android profile worked.

@nicoletto Were you able to try my workaround?