Failed to connect to NC

Hi, I am unable to connect to nc server. I get the following error:
'Failed to connect to Nextcloud at http://192.168.x.x/nextcloud/status.php: Error transferring http:192.168.x.x/nextcloud/status.php - server replied: Internal Server Error.

Nextcloud 13.0.0
Debian 9
log from apache2:

PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()\n#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()\n#4 /var/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)\n#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Obj in /var/www/nextcloud/lib/private/DB/Connection.php on line 64

php -v
PHP 7.0.27-0+deb9u1 (cli) (built: Jan 5 2018 13:51:52) ( NTS )
Copyright © 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright © 1998-2017 Zend Technologies
with Zend OPcache v7.0.27-0+deb9u1, Copyright © 1999-2017, by Zend Technologies

Any help appreciated thanks.

it’s still not clear if you can connect to your nc via browser and/or shell - we would need your config.php

then: did you try
http(s)://192.168.0.28/nextcloud
http(s)://192.168.0.28

Im unable to connect via browser nor shell.
http(s)://192.168.0.28/nextcloud/ --> blank page
http(s)://192.168.0.28 --> reaches the apache2 server page

/var/www/nextcloud# sudo -u www-data php occ status
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:64
Stack trace:

config php:
<?php
$CONFIG = array (
‘instanceid’ => xxx
’passwordsalt’ => xxx
’secret’ => xxx
’trusted_domains’ =>
array (
0 => ‘192.168.0.28’,
),
‘datadirectory’ => ‘/var/www/nextcloud/data’,
‘overwrite.cli.url’ => ‘http ://192.168.0.28/nextcloud’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘13.0.0.14’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => xxx
’dbpassword’ => xxx
’installed’ => true,
‘updater.secret’ => xxx
’maintenance’ => false,
‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘loglevel’ => 0,
);

There might ring a bell :wink:

Could you check the database status?

1 Like

How can I check the database status?

I don’t know which database you use. Probably with:
systemctl status mariadb
or
systemctl status mysql

Does it say

Active: active (running) since …

?

Second possibility …
I’m not to familiar with Debian, so please pick the command which works in your environment:

netstat -an | grep 3306
ss -an | grep 3306

Do you see any output, that something listens on that port? Like

tcp LISTEN 0 0 *:3306 *:*

Apart from that, especially when the DB is not running, you might have a look into the logs or the journal (journalctl).

I am not getting anything from both commands
netstat -an | grep 3306
ss -an | grep 3306

systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-02-21 18:28:51 CET; 6min ago
  Process: 3916 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 3826 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment
  Process: 3821 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 3818 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 3916 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"


Feb 21 18:28:47 Lianli systemd[1]: Starting MariaDB database server...
Feb 21 18:28:48 Lianli mysqld[3916]: 2018-02-21 18:28:48 140267619983936 [Note] /usr/sbin/mysqld (mysqld 10.1.26-MariaDB-0+deb9u1) starting as process 3916 ...
Feb 21 18:28:51 Lianli systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 21 18:28:51 Lianli systemd[1]: Failed to start MariaDB database server.
Feb 21 18:28:51 Lianli systemd[1]: mariadb.service: Unit entered failed state.
Feb 21 18:28:51 Lianli systemd[1]: mariadb.service: Failed with result 'exit-code'

error log:
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.

2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: The InnoDB memory heap is disabled
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Using Linux native AIO
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Using SSE crc32 instructions
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Completed initialization of buffer pool
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Highest supported file format is Barracuda.
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: 128 rollback segment(s) are active.
2018-02-21 16:54:57 140627133432384 [Note] InnoDB: Waiting for purge to start
2018-02-21 16:54:57 140627133432384 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.36-82.1 started; log sequence number 135039151
2018-02-21 16:54:57 140626473514752 [Note] InnoDB: Dumping buffer pool(s) not yet started
2018-02-21 16:54:57 140627133432384 [Note] Plugin 'FEEDBACK' is disabled.
2018-02-21 16:54:57 140627133432384 [Note] Recovering after a crash using tc.log
2018-02-21 16:54:57 140627133432384 [ERROR] Can't init tc log
2018-02-21 16:54:57 140627133432384 [ERROR] Aborting

Yes, this is because:

Maybe it is this you should aiming for. Can you fix that?

Afterwards check if the database starts again:

systemctl start mariadb

Problem solved. I deleted tc.log (it was 0 bytes) and restarted the db, it works fine now.
Problem may have appeared because my system drive is almost full.
Thanks everyone for your help!

2 Likes

Awesome! Glad your server is running again! :slight_smile:

having simillar issue.
mariadb.service - MariaDB 10.1.34 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Mon 2018-08-20 16:29:34 WEST; 14min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 8820 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 8805 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Process: 8688 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery; [ $? -eq 0 ] && systemctl set-environment _WSRE
Process: 8682 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 8671 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 8776 (mysqld)
Status: “Taking your SQL requests now…”
Tasks: 27 (limit: 4915)
CGroup: /system.slice/mariadb.service
└─8776 /usr/sbin/mysqld

ago 20 16:29:33 dnscloud.dnsolutions.pt systemd[1]: Starting MariaDB 10.1.34 database server…
ago 20 16:29:34 dnscloud.dnsolutions.pt mysqld[8776]: 2018-08-20 16:29:34 139674875247744 [Note] /usr/sbin/mysqld (mysqld 10.1.34-MariaDB-0ubuntu0.18.04.1) starting as proce
ago 20 16:29:34 dnscloud.dnsolutions.pt /etc/mysql/debian-start[8823]: /usr/bin/mysql_upgrade: the ‘–basedir’ option is always ignored
ago 20 16:29:34 dnscloud.dnsolutions.pt /etc/mysql/debian-start[8823]: Looking for ‘mysql’ as: /usr/bin/mysql
ago 20 16:29:34 dnscloud.dnsolutions.ptt /etc/mysql/debian-start[8823]: Looking for ‘mysqlcheck’ as: /usr/bin/mysqlcheck
lines 1-23


tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

i’m also getting this everytime i use occ commands

An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /var/www/nextcloud/lib/private/DB/ConnectionFactory.php(152): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /var/www/nextcloud/lib/private/Server.php(628): OC\DB\ConnectionFactory->getConnection(‘mysql’, Array)
#8 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
#9 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘OCP\IDBConnecti…’)
#10 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OCP\IDBConnecti…’)
#11 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query(‘OCP\IDBConnecti…’)
#12 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
#13 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘DatabaseConnect…’)
#14 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘DatabaseConnect…’)
#15 /var/www/nextcloud/lib/private/Server.php(1511): OC\ServerContainer->query(‘DatabaseConnect…’)
#16 /var/www/nextcloud/lib/private/Server.php(332): OC\Server->getDatabaseConnection()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘OC\Authenticati…’)
#19 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Authenticati…’)
#20 /var/www/nextcloud/lib/private/Server.php(336): OC\ServerContainer->query(‘OC\Authenticati…’)
#21 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘OC\Authenticati…’)
#23 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Authenticati…’)
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query(‘OC\Authenticati…’)
#25 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘OC\Authenticati…’)
#27 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Authenticati…’)
#28 /var/www/nextcloud/lib/private/Server.php(352): OC\ServerContainer->query(‘OC\Authenticati…’)
#29 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘OCP\IUserSessio…’)
#31 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OCP\IUserSessio…’)
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query(‘OCP\IUserSessio…’)
#33 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘UserSession’)
#35 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘UserSession’)
#36 /var/www/nextcloud/lib/private/Server.php(1380): OC\ServerContainer->query(‘UserSession’)
#37 /var/www/nextcloud/lib/private/Server.php(688): OC\Server->getUserSession()
#38 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
#39 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘OC\App\AppManag…’)
#40 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\App\AppManag…’)
#41 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query(‘OC\App\AppManag…’)
#42 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
#43 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet(‘AppManager’)
#44 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘AppManager’)
#45 /var/www/nextcloud/lib/private/Server.php(1684): OC\ServerContainer->query(‘AppManager’)
#46 /var/www/nextcloud/lib/private/legacy/app.php(332): OC\Server->getAppManager()
#47 /var/www/nextcloud/lib/private/legacy/app.php(113): OC_App::getEnabledApps()
#48 /var/www/nextcloud/lib/base.php(662): OC_App::loadApps(Array)
#49 /var/www/nextcloud/lib/base.php(1081): OC::init()
#50 /var/www/nextcloud/console.php(46): require_once(’/var/www/nextcl…’)
#51 /var/www/nextcloud/occ(11): require_once(’/var/www/nextcl…’)

I ran into this error after updating linux, which changed php’s default version. Check for a mismatch of php-versions between

  • php, used by nextcloud ( Settings --> Admin ). E.g. php5.6
  • the default php-version, used in the command line to invoke the occ command ( php --version ). E.g. php7.3

In case of a mismatch of these versions, you might just run the occ commands with the php-version, nextcloud is using:
php5.6 occ ...

Best,
Bernd

To change the version for the console on Ubuntu, use

sudo update-alternatives --set php /usr/bin/php5.6
sudo update-alternatives --set php /usr/bin/php7.0
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set php /usr/bin/php7.2