"This site can’t be reached" after upgrading Ubuntu to v22

Nextcloud version (eg, 20.0.5): 24
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22

The issue you are facing:
Yesterday I needed to upgrade my Ubuntu machine to v22 after which NC was up and running as normal. Today I figured out that my AnyDesk application is not working so I uninstalled it and installed it again (this requires turning off the machine and moving it close to a monitor). After I finish the installation, I turned off the machine to move it back to its place and when I powered it on, I realized that NC was not running anymore and when I try to reach its website/domain i get the error " This site can’t be reached". I get it also when trying to reach it in different networks and by IP as well.

I have to say also, that I needed the upgrade and the remote access to configure letsencrypt certbot certificate renewal and while I was doing this I got several errors and in the end I was banned for 24hours for sending too much certificate requests. But I believe the ban is for requestin new certificates, not for current (valid) ones. The system reboot happened after this event.

The output of your Nextcloud log in Admin > Logging:

not muche here, this is the las event (from yesterday)

{"reqId":"3MPMIynWoEVX2PvWHUn0","level":3,"time":"2022-09-13T17:51:57+00:00","remoteAddr":"149.62.xxx.xxx","user":"--","app":"core","method":"GET","url":"/index.php/s/xxxx/download?path=&files=xxxx.MP4","message":"Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory","userAgent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1","version":"24.0.4.1","exception":{"Exception":"Doctrine\\DBAL\\Exception","Message":"Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory","Code":2002,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1519,"function":"connect","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1041,"function":"getWrappedConnection","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":345,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":281,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":166,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1339,"function":"get","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1390,"function":"getCacheEntry","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/Root.php","line":205,"function":"getFileInfo","class":"OC\\Files\\View","type":"->"},{"function":"get","class":"OC\\Files\\Node\\Root","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/LazyFolder.php","line":72,"function":"call_user_func_array"},{"file":"/var/www/nextcloud/lib/private/Files/Node/LazyFolder.php","line":149,"function":"__call","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/AppData/AppData.php","line":141,"function":"get","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/JSCombiner.php","line":88,"function":"getFolder","class":"OC\\Files\\AppData\\AppData","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/JSResourceLocator.php","line":123,"function":"process","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/JSResourceLocator.php","line":76,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":377,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":205,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":185,"function":"__construct","class":"OC\\TemplateLayout","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":334,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/nextcloud/index.php","line":74,"function":"printExceptionErrorPage","class":"OC_Template","type":"::"}],"File":"/var/www/nextcloud/lib/private/DB/Connection.php","Line":139,"CustomMessage":"--"}}

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

<?php
$CONFIG = array (
  'default_phone_region' => 'BG',
  'instanceid' => 'xxxx',
  'passwordsalt' => 'xxxxxxxxxxx',
  'secret' => 'xxxxxx',
  'trusted_domains' => 
  array (
    0 => 'cloud.domain.com',
    1 => 'local IP',
    2 => 'public IP',
    3 => 'www.cloud.domain.com',
  ),
  'datadirectory' => '/mnt/md0/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.4.1',
  'overwrite.cli.url' => 'http://cloud.domain.com',
  'dbname' => 'xx',
  'dbhost' => 'xx',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xx',
  'dbpassword' => 'xx',
  'installed' => true,
  'filelocking.enabled' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '127.0.0.1',
    'port' => 6379,
  ),
  'mail_from_address' => 'office',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'xx',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtphost' => 'xx',
  'mail_smtpport' => 'xx',
  'mail_smtpsecure' => 'xx',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

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

[Wed Sep 14 00:00:04.225986 2022] [ssl:warn] [pid 1131] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 00:00:04.231120 2022] [mpm_prefork:notice] [pid 1131] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Sep 14 00:00:04.231259 2022] [core:notice] [pid 1131] AH00094: Command line: '/usr/sbin/apache2'
[Wed Sep 14 08:37:46.805773 2022] [mpm_prefork:notice] [pid 1131] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Sep 14 08:45:53.409504 2022] [ssl:warn] [pid 1030] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 08:46:06.609386 2022] [ssl:warn] [pid 1150] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 08:46:06.623560 2022] [mpm_prefork:notice] [pid 1150] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Sep 14 08:46:06.623603 2022] [core:notice] [pid 1150] AH00094: Command line: '/usr/sbin/apache2'
[Wed Sep 14 08:58:16.584145 2022] [mpm_prefork:notice] [pid 1150] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Sep 14 09:24:32.630240 2022] [ssl:warn] [pid 1146] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 09:24:39.509759 2022] [ssl:warn] [pid 1256] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 09:24:39.524328 2022] [mpm_prefork:notice] [pid 1256] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Sep 14 09:24:39.524368 2022] [core:notice] [pid 1256] AH00094: Command line: '/usr/sbin/apache2'
[Wed Sep 14 10:04:47.516219 2022] [mpm_prefork:notice] [pid 1256] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Sep 14 10:06:08.023212 2022] [ssl:warn] [pid 1120] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 10:06:16.015685 2022] [ssl:warn] [pid 1282] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 10:06:16.030070 2022] [mpm_prefork:notice] [pid 1282] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Sep 14 10:06:16.030119 2022] [core:notice] [pid 1282] AH00094: Command line: '/usr/sbin/apache2'
[Wed Sep 14 11:24:12.450138 2022] [mpm_prefork:notice] [pid 1282] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Sep 14 11:25:31.164412 2022] [ssl:warn] [pid 1174] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 11:25:40.816765 2022] [ssl:warn] [pid 1333] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 11:25:40.831059 2022] [mpm_prefork:notice] [pid 1333] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Sep 14 11:25:40.831098 2022] [core:notice] [pid 1333] AH00094: Command line: '/usr/sbin/apache2'
[Wed Sep 14 11:43:52.583018 2022] [mpm_prefork:notice] [pid 1333] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Sep 14 11:43:52.663373 2022] [ssl:warn] [pid 5527] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 11:43:52.715787 2022] [ssl:warn] [pid 5530] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 11:43:52.728254 2022] [mpm_prefork:notice] [pid 5530] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Sep 14 11:43:52.728301 2022] [core:notice] [pid 5530] AH00094: Command line: '/usr/sbin/apache2'
[Wed Sep 14 11:46:28.251313 2022] [mpm_prefork:notice] [pid 5530] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Sep 14 11:47:53.570539 2022] [ssl:warn] [pid 1182] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 11:48:02.255054 2022] [ssl:warn] [pid 1339] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Wed Sep 14 11:48:02.269093 2022] [mpm_prefork:notice] [pid 1339] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Sep 14 11:48:02.269145 2022] [core:notice] [pid 1339] AH00094: Command line: '/usr/sbin/apache2'

Don’t know even where to start from, so I wiill be glad to receive any hints.
Will provide more info if needed.

Thank you in advance!

After many tries and executed commands in terminal, I see that I can access NC locally now. Not sure which was the exact commant that fixed it.

But still, I am not able to access from a remote network (trying via domain & static IP). Already checked router settings but everything seems as it should be (and as it was before).

Maybe I need to allow remote access somewhere.

Any advice would be appreciated!!

So the problem turned out to be in the firewall. Probably installing the new Ubuntu version changed firewall settings. I allowed incoming requests on my NC ports and everything seems to be OK for now.

these commands fixed the problem if anybody else encounters the same problem:

sudo ufw allow 80
sudo ufw allow 443

In your case you may be using different ports, so edit if needed