Slow / impossible Login to NC with apache2 error The timeout specified has expired

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 23.0.2.1
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.3 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.41
PHP version (eg, 7.4): php7.4 / php-fpm7.4

The issue you are facing:
Entering the NC-URL loads very fast the login screen of nextcloud like it should be. But if i try to login with my credentials, after a long loading time the Error 504 Gateway Timeout occurs.

Is this the first time you’ve seen this error? (Y/N): Yes and No
It was also very slow with the NC Version 22, but i was able to login. With NC 23 login is now impossible.

Steps to replicate it:

n/a

The output of your Nextcloud log in Admin > Logging:

n/a

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

<?php
$CONFIG = array (
  'instanceid' => 'oclflxcxijh4',
  'passwordsalt' => 'xxxxxxxx',
  'secret' => 'xxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => '192.168.188.15',
    1 => 'nc.z8v.de',
  ),
  'datadirectory' => '/media/storage0/nextcloud/',
  'dbtype' => 'mysql',
  'version' => '23.0.2.1',
  'overwrite.cli.url' => 'http://192.168.188.15/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxxxxxxxxx',
  'dbpassword' => 'xxxxxxxxxx',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'smtp.strato.de',
  'mail_domain' => 'xxxxxxxxxx',
  'mail_smtpauth' => 1,
  'mail_smtpsecure' => 'ssl',
  'mail_smtpname' => 'xxxxxxxxxx',
  'mail_smtppassword' => 'xxxxxxxxxx',
  'mail_smtpport' => '465',
  'default_phone_region' => 'DE',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'updater.secret' => 'xxxxxxxxxx',
);

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

87.188.27.216 - - [22/Feb/2022:09:10:17 +0100] "POST /index.php/login HTTP/2.0" 504 703 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0"
87.188.27.216 - - [22/Feb/2022:09:15:17 +0100] "GET /favicon.ico HTTP/2.0" 404 771 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0"
79.253.193.29 - - [22/Feb/2022:09:15:19 +0100] "PROPFIND /remote.php/dav/files/Freisei/NXC HTTP/1.1" 207 5863 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19042 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
87.188.27.216 - - [22/Feb/2022:09:15:26 +0100] "PROPFIND /remote.php/dav/files/Maximilian/ HTTP/1.1" 207 5875 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19044 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
79.253.193.29 - - [22/Feb/2022:09:15:49 +0100] "PROPFIND /remote.php/dav/files/Freisei/NXC HTTP/1.1" 207 5863 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19042 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
87.188.27.216 - - [22/Feb/2022:09:15:56 +0100] "PROPFIND /remote.php/dav/files/Maximilian/ HTTP/1.1" 207 5875 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19044 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
79.253.193.29 - - [22/Feb/2022:09:16:19 +0100] "PROPFIND /remote.php/dav/files/Freisei/NXC HTTP/1.1" 207 5863 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19042 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
87.188.27.216 - - [22/Feb/2022:09:16:26 +0100] "PROPFIND /remote.php/dav/files/Maximilian/ HTTP/1.1" 207 5875 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19044 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
79.253.193.29 - - [22/Feb/2022:09:16:49 +0100] "PROPFIND /remote.php/dav/files/Freisei/NXC HTTP/1.1" 207 5863 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19042 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
87.188.27.216 - - [22/Feb/2022:09:16:56 +0100] "PROPFIND /remote.php/dav/files/Maximilian/ HTTP/1.1" 207 5875 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19044 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
79.253.193.29 - - [22/Feb/2022:09:17:19 +0100] "PROPFIND /remote.php/dav/files/Freisei/NXC HTTP/1.1" 207 5863 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19042 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
87.188.27.216 - - [22/Feb/2022:09:17:26 +0100] "PROPFIND /remote.php/dav/files/Maximilian/ HTTP/1.1" 207 5875 "-" "Mozilla/5.0 (Windows) mirall/3.4.1stable-Win64 (build 20211221) (Nextcloud, windows-10.0.19044 ClientArchitecture: x86_64 OsArchitecture: x86_64)"


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

[Tue Feb 22 09:12:45.124303 2022] [proxy_fcgi:error] [pid 1640614:tid 140544090380032] (70007)The timeout specified has expired: [client 87.188.27.216:51903] AH01075: Error dispatching request to : (polling)
[Tue Feb 22 09:12:57.864309 2022] [proxy_fcgi:error] [pid 1640614:tid 140544048375552] (70007)The timeout specified has expired: [client 87.188.27.216:51903] AH01075: Error dispatching request to : (polling)
[Tue Feb 22 09:13:01.196307 2022] [proxy_fcgi:error] [pid 1640614:tid 140544073578240] (70007)The timeout specified has expired: [client 87.188.27.216:51903] AH01075: Error dispatching request to : (polling)
[Tue Feb 22 09:13:05.332338 2022] [proxy_fcgi:error] [pid 1640614:tid 140544056776448] (70007)The timeout specified has expired: [client 87.188.27.216:51903] AH01075: Error dispatching request to : (polling)
[Tue Feb 22 09:13:06.064300 2022] [proxy_fcgi:error] [pid 1640614:tid 140544081979136] (70007)The timeout specified has expired: [client 87.188.27.216:51903] AH01075: Error dispatching request to : (polling)
[Tue Feb 22 09:15:17.480310 2022] [proxy_fcgi:error] [pid 1640614:tid 140544098780928] (70007)The timeout specified has expired: [client 87.188.27.216:51935] AH01075: Error dispatching request to : (polling)

Login now is possible again, i’ve changed the timeouts in /etc/php/7.4/fpm/php.ini:

max_execution_time = 600
max_input_time = 600

But the main problem exists still: Login is very slow and takes longer than 60s. After Login, NC is fast as it should be.

Hi @deadrabbit , have you enabled opcache or memory cache?
see this doc : https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html

Yes. In php.ini i’ve set the following values:

opcache.revalidate_freq = 60
opcache.save_comments = 1

Any other ideas? Are there more log files needed?

Maximilian

Hi @deadrabbit, I have any idea how to solve your issue…
Have you some log about this in your nextcloud log file?

HI @Mageunic,

here is the log from NC with loglevel 0. I’ve started login at 11.15 and i finished login at 11.21. Therefore it took approximately 6 minutes to login.

@deadrabbit, i found any error about your issue … I want to know if you have set up a cronjob task ?

Have you set these value too ?

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128

No, not everyone. I’ve done this now, but it doesnt’t change anything.

No, i didn’t have set up any cronjob.

@deadrabbit

if you haven’t set these 2 lines :
opcache.enable=1
opcache.enable_cli=1

opcache was not enabled

have you restart apache or nginx ( the one used for nextcloud) ?

A cronjob task is used to reduce load of your server. This task is used to run background task of nextcloud like notification sender, some apps like duplicate or other with script to detect something inside your files, they have a background task which used many perfommance of your server.
by default nextcloud run theses background task only when an action of a user is run like a login or navigation through files or parameters.

More informations here : https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html

when you log into your account, can you check your memory and CPU load of your server?

have you tried to log into nextcloud with another device ?

Yes, i’ve restarted the Apache2 Service with

sudo systemctl restart apache2.service

Is the path of my php.ini correct? In my path /etc/php/7.5 are the following subfolders:
apache2 cli fpm mods-available phpdbg
I’ve changed the settings in /etc/php/7.4/fpm/php.ini. Is this the correct file?

I’ve setup a cron job as described in the guide. I’ve executed the cron job manually and tried to login another time. Same behavoir as before.

In my point of view, the server load isn’t very high. The CPU-Load is about 20%. Only the values for Load average are relatively high: Between 3 and 7.

Yes, same behavoir with different browsers on different devices.

@deadrabbit

I set the values in this file: /etc/php/7.4/apache2/php.ini

@Mageunic
I have now set the values in the apache2 subfolder. After that, i’ve installed the opcache-gui to monitor caching.

If i call the nextcloud instance and login there, files have been cached. Also the memory and the load seems to be ok. See the pdf atached.

So, in my point of view, it seems to be that caching works. But doesn’t change anything at the login speed.

opcache.pdf (655,2 KB)

Good day,

Not to hijack this thread, but it appears to be the same issues that I’m currently facing with a very similar setup.

My setup is Nextcloud running in a virtual machine, with a MariaDB v10.6.7 backend on the host machine.
Recently noticed that MariaDB had a high cpu load, and that Nextcloud didn’t respond.

Log In page loading fine, but time out when trying to actually log-in.

The MariaDB database server was stuck, had to force a shut-down to restart it.

After restarting MariaDB, log-in worked again, and everything appeared to be fine for a while, after which Nextcloud again became non-responsive and MariaDB started to eat up CPU.

Not been able to find out what is going on with the Database server.

Have enabled “slowquerry” logging on MariaDB. So far that have not returned any useful information.

While this was happening I tried to run mariadb-check --verbose [nameofnextclouddb]
This got stuck when checking the “oc_filecache” table, and wouldn’t complete.

Another forced restart of MariaDB, allowed the mariadb-check to complete without finding any issues.

The strange thing is that the other applications using the same MariaDB instance is not affected by this, they respond just fine, even though Nextcloud database is hanging.

Again, apologise if this just clutters the above.

@deadrabbit I don’t know how to help you more … I can’t see where the problem could come from