Very long time there is authorization in the cloud. In logs: ServerNotAvailableException: Lost connection to LDAP server

Nextcloud version (eg, 12.0.4):
Operating system and version (eg, CentOS Linux release 7.4.1708):
Apache or nginx version (eg, nginx/1.12.2):
PHP version (eg, 7.1.10):

Is this the first time you’ve seen this error?: No, The error occurs constantly

Can you reliably replicate it? (If so, please outline steps): No, Error appears then disappears

The issue you are facing: Very long time there is authorization in the cloud. Often I see a message from nginx: Connection timed out. Plese help me.

The output of your Nextcloud log in Admin > Logging:

Error	no app in context	Symfony\Component\Routing\Exception\RouteNotFoundException: Unable to generate a URL for the named route "theming.Theming.getLogo" as such route does not exist.
/usr/share/nginx/html/nextcloud/lib/private/Route/Router.php - line 339: Symfony\Component\Routing\Generator\UrlGenerator->generate('theming.Theming...', Array, 1)
/usr/share/nginx/html/nextcloud/lib/private/URLGenerator.php - line 77: OC\Route\Router->generate('theming.Theming...', Array)
/usr/share/nginx/html/nextcloud/apps/theming/lib/ThemingDefaults.php - line 165: OC\URLGenerator->linkToRoute('theming.Theming...')
/usr/share/nginx/html/nextcloud/lib/public/Defaults.php - line 186: OCA\Theming\ThemingDefaults->getLogo(true)
/usr/share/nginx/html/nextcloud/core/templates/layout.guest.php - line 45: OCP\Defaults->getLogo()
/usr/share/nginx/html/nextcloud/lib/private/Template/Base.php - line 176: include('/usr/share/ngin...')
/usr/share/nginx/html/nextcloud/lib/private/Template/Base.php - line 151: OC\Template\Base->load('/usr/share/ngin...', NULL)
/usr/share/nginx/html/nextcloud/lib/private/legacy/template.php - line 202: OC\Template\Base->fetchPage(NULL)
/usr/share/nginx/html/nextcloud/lib/private/legacy/template.php - line 224: OC_Template->fetchPage()
/usr/share/nginx/html/nextcloud/lib/private/Template/Base.php - line 132: OC_Template->fetchPage()
/usr/share/nginx/html/nextcloud/core/templates/403.php - line 7: OC\Template\Base->printPage()
{main}
2017-12-23T11:28:22+0300


Error	core	Error while running background job (OC\ServerNotAvailableException): Lost connection to LDAP server.
OCA\Files\BackgroundJob\ScanFiles ):
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/LDAP.php - line 368: OCA\User_LDAP\LDAP->processLDAPError(Resource id #659)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/LDAP.php - line 295: OCA\User_LDAP\LDAP->postFunctionCall()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/LDAP.php - line 46: OCA\User_LDAP\LDAP->invokeLDAPMethod(*** sensitive parameters replaced ***)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 614: OCA\User_LDAP\LDAP->bind(*** sensitive parameters replaced ***)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 539: OCA\User_LDAP\Connection->bind(*** sensitive parameters replaced ***)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 172: OCA\User_LDAP\Connection->establishConnection()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 180: OCA\User_LDAP\Connection->init()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Access.php - line 1005: OCA\User_LDAP\Connection->getConnectionResource()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Access.php - line 1166: OCA\User_LDAP\Access->executeSearch('(&(&(|(objectcl...', Array, Array, 500, '500')
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Access.php - line 890: OCA\User_LDAP\Access->search('(&(&(|(objectcl...', Array, Array, 500, '500')
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Access.php - line 806: OCA\User_LDAP\Access->searchUsers('(&(&(|(objectcl...', Array, 500, '500')
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/User_LDAP.php - line 270: OCA\User_LDAP\Access->fetchListOfUsers('(&(&(|(objectcl...', Array, 500, '500')
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/User_Proxy.php - line 155: OCA\User_LDAP\User_LDAP->getUsers('', 500, '500')
/usr/share/nginx/html/nextcloud/lib/private/User/Manager.php - line 237: OCA\User_LDAP\User_Proxy->getUsers('', 500, '500')
/usr/share/nginx/html/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php - line 101: OC\User\Manager->search('', 500, '500')
/usr/share/nginx/html/nextcloud/lib/private/BackgroundJob/Job.php - line 59: OCA\Files\BackgroundJob\ScanFiles->run(NULL)
/usr/share/nginx/html/nextcloud/lib/private/BackgroundJob/TimedJob.php - line 54: OC\BackgroundJob\Job->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log))
/usr/share/nginx/html/nextcloud/cron.php - line 124: OC\BackgroundJob\TimedJob->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log))
{main}
2017-12-23T11:15:29+0300

Error	index	OC\ServerNotAvailableException: Lost connection to LDAP server.
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/LDAP.php - line 368: OCA\User_LDAP\LDAP->processLDAPError(Resource id #107)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/LDAP.php - line 295: OCA\User_LDAP\LDAP->postFunctionCall()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/LDAP.php - line 46: OCA\User_LDAP\LDAP->invokeLDAPMethod(*** sensitive parameters replaced ***)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 614: OCA\User_LDAP\LDAP->bind(*** sensitive parameters replaced ***)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 539: OCA\User_LDAP\Connection->bind(*** sensitive parameters replaced ***)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 172: OCA\User_LDAP\Connection->establishConnection()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Connection.php - line 180: OCA\User_LDAP\Connection->init()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Access.php - line 172: OCA\User_LDAP\Connection->getConnectionResource()
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/User_LDAP.php - line 297: OCA\User_LDAP\Access->readAttribute('cn=\xD0\xB0\xD0\xBD\xD1\x82\xD0\xBE\xD0\xBD \xD1...', '', '(&(|(objectclas...')
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/User_LDAP.php - line 352: OCA\User_LDAP\User_LDAP->userExistsOnLDAP(Object(OCA\User_LDAP\User\User))
[internal function] OCA\User_LDAP\User_LDAP->userExists('B1B52D52-5D7C-4...')
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/User_Proxy.php - line 77: call_user_func_array(Array, Array)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/Proxy.php - line 150: OCA\User_LDAP\User_Proxy->walkBackends('B1B52D52-5D7C-4...', 'userExists', Array)
/usr/share/nginx/html/nextcloud/apps/user_ldap/lib/User_Proxy.php - line 169: OCA\User_LDAP\Proxy->handleRequest('B1B52D52-5D7C-4...', 'userExists', Array)
/usr/share/nginx/html/nextcloud/lib/private/User/Manager.php - line 137: OCA\User_LDAP\User_Proxy->userExists('B1B52D52-5D7C-4...')
/usr/share/nginx/html/nextcloud/lib/private/User/Manager.php - line 181: OC\User\Manager->get('B1B52D52-5D7C-4...')
/usr/share/nginx/html/nextcloud/lib/private/Share20/Share.php - line 159: OC\User\Manager->userExists('B1B52D52-5D7C-4...')
/usr/share/nginx/html/nextcloud/apps/files_sharing/lib/Controller/ShareController.php - line 264: OC\Share20\Share->getNode()
/usr/share/nginx/html/nextcloud/apps/files_sharing/lib/Controller/ShareController.php - line 294: OCA\Files_Sharing\Controller\ShareController->validateShare(Object(OC\Share20\Share))
[internal function] OCA\Files_Sharing\Controller\ShareController->showShare('o9oaZnH6014MGds', '')
/usr/share/nginx/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 160: call_user_func_array(Array, Array)
/usr/share/nginx/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 90: OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\Files_Sharing\Controller\ShareController), 'showShare')
/usr/share/nginx/html/nextcloud/lib/private/AppFramework/App.php - line 114: OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Files_Sharing\Controller\ShareController), 'showShare')
/usr/share/nginx/html/nextcloud/lib/public/AppFramework/App.php - line 136: OC\AppFramework\App main('ShareController', 'showShare', Object(OC\AppFramework\DependencyInjection\DIContainer))
/usr/share/nginx/html/nextcloud/core/routes.php - line 105: OCP\AppFramework\App->dispatch('ShareController', 'showShare')
[internal function] OC\Route\Router->{closure}(Array)
/usr/share/nginx/html/nextcloud/lib/private/Route/Router.php - line 299: call_user_func(Object(Closure), Array)
/usr/share/nginx/html/nextcloud/lib/base.php - line 1004: OC\Route\Router->match('/s/o9oaZnH6014M...')
/usr/share/nginx/html/nextcloud/index.php - line 48: OC handleRequest()
{main}
2017-12-23T11:04:25+0300


Fatal	webdav	Sabre\DAV\Exception\ServiceUnavailable: OC\ServerNotAvailableException: Lost connection to LDAP server.
/usr/share/nginx/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php - line 201: OCA\DAV\Connector\Sabre\Auth->check(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/usr/share/nginx/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php - line 150: Sabre\DAV\Auth\Plugin->check(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
[internal function] Sabre\DAV\Auth\Plugin->beforeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/usr/share/nginx/html/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/usr/share/nginx/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 466: Sabre\Event\EventEmitter->emit('beforeMethod', Array)
/usr/share/nginx/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/usr/share/nginx/html/nextcloud/apps/dav/appinfo/v1/webdav.php - line 76: Sabre\DAV\Server->exec()
/usr/share/nginx/html/nextcloud/remote.php - line 162: require_once('/usr/share/ngin...')
{main}
2017-12-23T11:00:21+0300

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

<?php
$CONFIG = array (
  'instanceid' => 'oc2b0xtd0a0p',
  'passwordsalt' => 'deleted',
  'secret' => 'deleted',
  'trusted_domains' =>
  array (
    0 => 'deleted',
  ),
  'datadirectory' => '/usr/share/nginx/html/nextcloud/data',
  'overwrite.cli.url' => 'https://deleted',
  'dbtype' => 'mysql',
  'version' => '12.0.4.3',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'deleted',
  'dbpassword' => 'deleted',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_from_address' => 'mailer',
  'mail_smtpmode' => 'php',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'deleted',
  'maintenance' => false,
  'loglevel' => 2,
  'updater.release.channel' => 'stable',
  'updater.secret' => 'deleted',
);

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

/var/log/nginx/error.log-20171223                                                                                                                                                                                                                  2526/2526              100%
2017/12/22 08:52:57 [error] 28286#28286: *113890 access forbidden by rule, client: 109.68.190.102, server: cloud.deteted, request: "GET /data/.ocdata?t=1513921979405 HTTP/2.0", host: "cloud.deteted"
2017/12/22 08:53:00 [error] 28286#28286: *113890 access forbidden by rule, client: 109.68.190.102, server: cloud.deteted, request: "GET /data/.ocdata?t=1513921981903 HTTP/2.0", host: "cloud.deteted"
2017/12/22 08:58:00 [error] 28286#28286: *113890 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 109.68.190.102, server: cloud.deteted, request: "POST /apps/user_ldap/ajax/testConfiguration.php HTTP/2.0", upstream: "fas
tcgi://unix:/var/run/php-fpm.sock", host: "cloud.deteted"
2017/12/22 09:54:17 [error] 28286#28286: *114314 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 109.68.190.102, server: cloud.deteted, request: "POST /login HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock",
host: "cloud.deteted"
2017/12/22 09:59:57 [error] 28286#28286: *114339 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 109.68.190.102, server: cloud.deteted, request: "POST /login HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock",
host: "cloud.deteted"
2017/12/22 10:05:57 [error] 28287#28287: *114377 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 109.68.190.102, server: cloud.deteted, request: "GET /favicon.ico HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.so
ck", host: "cloud.deteted"
2017/12/22 14:20:01 [error] 28286#28286: *116065 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 213.87.130.51, server: cloud.deteted, request: "POST /login HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock", h
ost: "cloud.deteted"
2017/12/22 14:25:02 [error] 28286#28286: *116065 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 213.87.130.51, server: cloud.deteted, request: "GET /favicon.ico HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.soc
k", host: "cloud.deteted", referrer: "https://cloud.deteted/login"
2017/12/22 16:27:47 [error] 28287#28287: *116899 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 91.207.170.230, server: cloud.deteted, request: "GET /s/9nzkqpuW5ZTO9Pu HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-
fpm.sock", host: "cloud.deteted"

I have Windows 2012 r2 Server and domain on this server.
Ldap settings in my nexctcloud:

Hi
Whether correctly I understand that this problem will be eliminated in 12.0.5?

Hi,I have the same questions when I configured the ldap.Are you solved this problem?

Not yet. I hope that there will not be a problem after updating to 12.0.5

In my case, the problem was related to the conflict of IP addresses. Check if you have another server with the same ip address as nexctcloud server.