Failed to connect to database

Steps to reproduce

  1. Login to system / or upload file
  2. Get error.
    This is happening very often.

Expected behaviour

Login to the page or upload a file.

Actual behaviour

Big error message.

Server configuration

Operating system: Ubuntu 16.10

Web server: Apache2

Database: MySQL

PHP version: 7

ownCloud version: (see ownCloud admin page) 10.0.4

Updated from an older ownCloud or fresh install: updates from v9

Where did you install ownCloud from:
Downloaded from and installed.

Signing status (ownCloud 9.0 and above):

Login as admin user into your ownCloud and access 
paste the results into and puth the link here.

The content of config/config.php:

Log in to the web-UI with an administrator account and click on
'admin' -> 'Generate Config Report' -> 'Download ownCloud config report'
This report includes the config.php settings, the list of activated apps
and other details in a well sanitized form.


If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your ownCloud installation folder

*ATTENTION:* Do not post your config.php file in public as is. Please use one of the above
methods whenever possible. Both, the generated reports from the web-ui and from occ config:list
consistently remove sensitive data. You still may want to review the report before sending.
If done manually then it is critical for your own privacy to dilligently
remove *all* host names, passwords, usernames, salts and other credentials before posting.
You should assume that attackers find such information and will use them against your systems.

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your ownCloud installation folder.

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

LDAP configuration (delete this part if not used)

With access to your command line run e.g.:
sudo -u www-data php occ ldap:show-config
from within your ownCloud installation folder

Without access to your command line download the data/owncloud.db to your local
computer or access your SQL server remotely and run the select query:
SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';

Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.

Client configuration


Operating system:


Web server error log

Insert your webserver log here

ownCloud log (data/owncloud.log)

Insert your ownCloud log here

Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log 
c) ...


could you paste the big error message here? :slight_smile:

I only have screenshot.

The first line is important. Can't connect to database.

You have the credentials for your ownCloud database in your config.php right? Try to log in your database using this credentials on command line

I am telling you that all my credentials are okay, the program works fine except sometimes it just breaks and throws this error.

So you can connect to your database with this credentials?

What about caching?


i am having this problem, or something similar…

what were your ideas on caching ? thanks for any help,

  • scott

Can you provide more information on this issue?

What exactly goes wrong at your instance?


i think this question of @scott451 is unrelated to the initial problem and it seems to be that it was also already solved in Owncloud can not find database during upgrade from 10.0.10 to 10.3.1