Importing is disabled because there are no address books available

Nextcloud version (eg, 20.0.5): 26.0.1 (NextcloudPi Installation)
Operating system and version (eg, Ubuntu 20.04): Debian GNU/Linux 11 (bullseye)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.56
PHP version (eg, 7.4): PHP 8.1.18

The issue you are facing:

As in the title I am having this issue which has been reported in the past.

Creating a new address book under contact settings, as suggested here, does not fix the issue since every time I refresh the page after doing so, I am once again greeted by importing is disabled because there are no address books available with a greyed out “New Contact” button.

When I try to add a new contact after creating an address book and not refreshing the page I get a pop up notification stating unable to update contact

The problem started after a recent update to the contacts app in late June 2023, which I was forced to undertake because I could not access the login screen or exit maintenance mode without proceeding. All of my contacts also vanished after this update, but luckily i had backups.

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

Steps to replicate it:

  1. Navigate to contacts section in Nextcloud GUI
  2. Under contact settings, add a new address book
    3a. Refresh the page, or navigate elsewhere and then back to contacts
    -or-
    3b. Without refreshing the page or navigating away, create a new contact.
    Upon attempting to save get a notification unable to update contact

The most significant log entry I have found, which occurs constantly whenever I attempt any of the above steps, is in the the system log viewed with tail -f /var/log/syslog:

NOTE: There is no user ncadmin on my box as I renamed this user within ncp-config during initial setup with no issues. The issues occurred after an update to the contacts app several weeks later.

Jul  6 11:51:34 nextcloudpi mariadbd[872]: 2023-07-06 11:51:34 646 [Warning] Aborted connection 646 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:51:34 nextcloudpi mariadbd[872]: 2023-07-06 11:51:34 649 [Warning] Aborted connection 649 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:51:34 nextcloudpi mariadbd[872]: 2023-07-06 11:51:34 650 [Warning] Aborted connection 650 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:51:34 nextcloudpi mariadbd[872]: 2023-07-06 11:51:34 651 [Warning] Aborted connection 651 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:51:34 nextcloudpi mariadbd[872]: 2023-07-06 11:51:34 652 [Warning] Aborted connection 652 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:51:35 nextcloudpi mariadbd[872]: 2023-07-06 11:51:35 662 [Warning] Aborted connection 662 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:51:35 nextcloudpi mariadbd[872]: 2023-07-06 11:51:35 663 [Warning] Aborted connection 663 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:51:36 nextcloudpi mariadbd[872]: 2023-07-06 11:51:36 664 [Warning] Aborted connection 664 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 11:52:40 nextcloudpi mariadbd[872]: 2023-07-06 11:52:40 673 [Warning] Aborted connection 673 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)

The permissions for the contacts app directory are set to www-data.
If this is a permission or database issue, how can I tell nextcloud to purge the contacts database and make a new one for my user?

Any assistance is deeply appreciated. Thank you all.

Other logs

Summary

The output of your Nextcloud log in Admin > Logging:

	
OC\Files\View->changeLock()

/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php - line 191:

OCA\DAV\Connector\Sabre\Node->changeLock()

/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 1137:

OCA\DAV\Connector\Sabre\File->put()

/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 492:

Sabre\DAV\Server->updateFile("*** sensiti ... *")

/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php - line 89:

Sabre\DAV\CorePlugin->httpPut()


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

<?php
$CONFIG = array (
  
  
  'datadirectory' => '/var/www/nextcloud/data/data',
  'dbtype' => 'mysql',
  'version' => '26.0.1.1',

  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncadmin',

  'installed' => true,

  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,

  ),
  'tempdirectory' => '/var/www/nextcloud/data/data/tmp',
  'mail_smtpmode' => 'sendmail',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'admin',
  'mail_domain' => 'ownyourbits.com',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'overwriteprotocol' => 'https',
  'maintenance' => false,
  'logfile' => '/var/www/nextcloud/data/data/nextcloud.log',
  
  'theme' => '',
  'loglevel' => '2',
  'log_type' => 'file',
  'enforce_theme' => '',
);

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

ul  6 12:32:40 nextcloudpi mariadbd[872]: 2023-07-06 12:32:40 1119 [Warning] Aborted connection 1119 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:40 nextcloudpi mariadbd[872]: 2023-07-06 12:32:40 1123 [Warning] Aborted connection 1123 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:40 nextcloudpi mariadbd[872]: 2023-07-06 12:32:40 1122 [Warning] Aborted connection 1122 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:40 nextcloudpi mariadbd[872]: 2023-07-06 12:32:40 1120 [Warning] Aborted connection 1120 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:40 nextcloudpi mariadbd[872]: 2023-07-06 12:32:40 1124 [Warning] Aborted connection 1124 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:40 nextcloudpi mariadbd[872]: 2023-07-06 12:32:40 1125 [Warning] Aborted connection 1125 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:41 nextcloudpi mariadbd[872]: 2023-07-06 12:32:41 1126 [Warning] Aborted connection 1126 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:41 nextcloudpi mariadbd[872]: 2023-07-06 12:32:41 1127 [Warning] Aborted connection 1127 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:32:42 nextcloudpi mariadbd[872]: 2023-07-06 12:32:42 1135 [Warning] Aborted connection 1135 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)
Jul  6 12:35:01 nextcloudpi CRON[6337]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)

I’m not sure what happened at your site. www-data refers to the filesystem. Contacts as well as calendar and calendar related data are stored in mysql/mariadb databases. There should be a user nwadmin. Just checked my site, there is a user nwadmin.

GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncadmin'@'localhost';
You can try to run this code here (adjust password/username). With this you change the privileges of ncadmin. After that it should work again.
Kind regards,
schBenedikt


My source:
https://technik.schächner.de/blog/2023/03/29/nextcloud-26-hub-4-installieren-2023/

Thank you so much @kjathome @SchBenedikt for getting back to me so quickly!

I will attempt the solution by @SchBenedikt but before I proceed, is there an occ or mysql command that I can use to verify the user owning the database? I just want to make sure I issue the command correctly.

The reason I ask is because even though in config.php the database owner is indicated as ncadmin, as pointed out by @kjathome, when I run awk -F: '{print $1}' /etc/passwd I don’t see a user ncadmin. Should it not appear in the output of this command?

The full output of this command looks thus:
NOTE: There is only one user of this NC instance, plus two accounts for ssh access.
I put *** next the the users I created when setting up the instance.

Summary

root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
_apt
systemd-network
systemd-resolve
systemd-timesync
messagebus
_rpc
sshd
statd
avahi
dnsmasq
mysql
postfix
redis
the_nextcloud_user_account***
prometheus
systemd-coredump
ssh_access_account_one***
ssh_acces_account_two***

Thanks again for your assistance

I ran the following:
sudo mysql --database nextcloud --execute “select Host, User from mysql.user; show grant;”
The select stmt return all known user (there should be ncadmin) show grants returns permissions.

Query results
+-----------+-------------+
| Host      | User        |
+-----------+-------------+
| localhost | mariadb.sys |
| localhost | mysql       |
| localhost | ncadmin     |
| localhost | root        |
+-----------+-------------+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                                                                 |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED VIA mysql_native_password USING 'xxxxxxx' OR unix_socket WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION                                                                                                             |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Thank you so much @kjathome and @SchBenedikt for your assistance!

I went ahead and issued the command to check the users in the database and indeed there is a user called ncadmin.

Please excuse my ignorance as I did not realize that the user names for the database and user names for the system are not always identical. It wasn’t until I saw ncadmin active on the database in realtime while one of my clients was uploading a file that I realized that my NC user is ncadmin on the database.

That being said, I went ahead and issued the command GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncadmin'@'localhost'; but unfortunately the issue persists.

In the system log I am also still seeing the line:

[Warning] Aborted connection 4131 to db: 'nextcloud' user: 'ncadmin' host: 'localhost' (Got an error reading communication packets)

appear multiple times whenever I load the contacts page or try to make a new address book.

I should note that this does not happen with the calendar, which functions as expected.

Is it possible that the portion of the database that stores the contacts somehow how got corrupted or altered in a way that would cause this?

Since the error suggests a problem with reading the communication packets, maybe it means the contents of that portion of the database are just unreadable somehow?

Thank you again for your patience and assistance.

Once I had this error too but can’t remember how I solved the issue.

First try to clear the opcache, either by webgui (admin panel) or shell command:
sudo bash -c 'source /usr/local/etc/library.sh && clear_opcache'

Additionally you may check all or contact related tables only. Just replace your database name as appropriate.

sudo mysql --database nextcloud --execute 'show tables;' | grep 'oc_' | awk '{print "check table " $0 ";"}' | sudo mysql --database nextcloud

Thank you to @kjathome and @SchBenedikt for your patience and assistance.

So, this is really crazy…

I’m not sure if one or more of the suggestions above fixed the problem, or if the problem “just fixed itself” somehow… but magically my issue has been resolved.

The problems went away after flashing a backup image of my server that i’d made with dd in case I made things worse. I had basically given up solving the issue after trying everything above and other things i could think of.

What’s crazy is that the dd image of the server was made with the issue unresolved, yet flashing it “fixed” the problem.

At this point I’m not going to question it and just be happy that everything works again.

I thank you all for your patience and assistance in this matter!

TL,DR

Summary

I had tried all the suggestions above, multiple reboots, combinations of the two, issueing the above database commands, messing with permissions in the commandline via SSH, and nothing worked.

I had given up on ever solving this and decided to start over from scratch, reinstalling NextcloudPi and just loading my data from a backup. Before doing so I manually backed up all my user data and made an image of the enire server using the dd command, just in case.

As luck would have it, starting over did not go well as a myriad of other problems (all of which would require their own threads) prevented me from getting up and running again as a new instance.

Finally, after days of torubleshooting I gave up again and just flashed the dd image of my old server (with the issue that started this thread unresolved) which I decided I would just use without the contact functionality…and somehow everything just works!

The contacts app had an address book already there, despite multiple failed prior attempts to make a new one, even after the above commands were issued. But now I can create and delete contacts with no problems.

A separate issue with the webGUI displaying all white with scrolling disabled similar to this issue has also “fixed itself”.