Android: "Could not find host"

Hi and thanks for Nextcloud!

After installing the Nextcloud app (3.13.0) from F-Droid, I entered “cloud.mb.sb” as the server address. This fails then with “Could not find host”.

The same address works when used in:

  • Nextcloud Talk (we can send messages)
  • DAVx⁵ (calendar data is synchronized)
  • a browser (I can log in)

I used this as my nginx configuration.

I can see in /var/log/nginx/access.log that the Android client indeed sends a request to the right server:

2001:871:23c:81e6:d16c:701c:7e26:d829 - - [11/Sep/2020:15:34:07 +0000] "GET /status.php HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Android) Nextcloud-android /3.13.0"

This is the first time I see this error.

Nextcloud version: 19.0.3
Operating system and version: Arch Linux 5.8.8
Apache or nginx version: nginx 1.18
PHP version: 7.4.10

Steps to replicate it:

  1. Download Nextcloud from F-Droid.
  2. Use “cloud.mb.sb” as the address.
  3. Hit the arrow to continue.

The output of your Nextcloud log in Admin > Logging:


{"reqId":"V4MnsxtEzfZnGqtPIYEU","level":3,"time":"2020-08-13T10:05:39+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"PHP","method":"GET","url":"/","message":"session_start(): A session had already been started - ignoring at /usr/share/webapps/nextcloud/lib/private/Session/Internal.php#209","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":""}
{"reqId":"V4MnsxtEzfZnGqtPIYEU","level":2,"time":"2020-08-13T10:05:39+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":""}
{"reqId":"V4MnsxtEzfZnGqtPIYEU","level":2,"time":"2020-08-13T10:05:39+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":""}
{"reqId":"V4MnsxtEzfZnGqtPIYEU","level":3,"time":"2020-08-13T10:05:39+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"jsresourceloader","method":"GET","url":"/","message":"Could not find resource js/setup.js to load","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":""}
{"reqId":"jjmCFCHmjNREnbtH6FSL","level":3,"time":"2020-08-13T10:13:14+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"PHP","method":"POST","url":"/index.php","message":"session_start(): A session had already been started - ignoring at /usr/share/webapps/nextcloud/lib/private/Session/Internal.php#209","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":""}
{"reqId":"jjmCFCHmjNREnbtH6FSL","level":2,"time":"2020-08-13T10:13:14+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":""}
{"reqId":"jjmCFCHmjNREnbtH6FSL","level":2,"time":"2020-08-13T10:13:14+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":""}
{"reqId":"0IKMlAOK3vmSAmMak0HZ","level":2,"time":"2020-08-13T10:14:32+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"--","app":"no app in context","method":"POST","url":"/login","message":"Login failed: admin (Remote IP: 2001:871:23c:8a:e0b3:6112:c84a:3842)","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":"19.0.1.1"}
{"reqId":"qf8GOZVVnF7EtmZssGql","level":3,"time":"2020-08-13T10:16:04+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"admin","app":"PHP","method":"GET","url":"/core/preview?fileId=8&c=81f420d104fd39646af9690bbfa1f3d3&x=250&y=250&forceIcon=0","message":"imagettftext(): Problem doing text layout at /usr/share/webapps/nextcloud/lib/private/Preview/TXT.php#92","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":"19.0.1.1"}
{"reqId":"qf8GOZVVnF7EtmZssGql","level":3,"time":"2020-08-13T10:16:04+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"admin","app":"PHP","method":"GET","url":"/core/preview?fileId=8&c=81f420d104fd39646af9690bbfa1f3d3&x=250&y=250&forceIcon=0","message":"imagettftext(): Problem doing text layout at /usr/share/webapps/nextcloud/lib/private/Preview/TXT.php#92","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":"19.0.1.1"}
{"reqId":"1GPtegt3kR3QurF68G2c","level":3,"time":"2020-08-13T10:40:32+00:00","remoteAddr":"2001:871:23c:8a:e0b3:6112:c84a:3842","user":"admin","app":"ocs_api","method":"POST","url":"/ocs/v2.php/cloud/users","message":{"Exception":"Swift_TransportException","Message":"Connection could not be established with host 127.0.0.1 :stream_socket_client(): unable to connect to 127.0.0.1:25 (Connection refused)","Code":0,"Trace":[{"function":"{closure}","class":"Swift_Transport_StreamBuffer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/share/webapps/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php","line":272,"function":"stream_socket_client"},{"file":"/usr/share/webapps/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php","line":58,"function":"establishSocketConnection","class":"Swift_Transport_StreamBuffer","type":"->"},{"file":"/usr/share/webapps/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php","line":143,"function":"initialize","class":"Swift_Transport_StreamBuffer","type":"->"},{"file":"/usr/share/webapps/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php","line":65,"function":"start","class":"Swift_Transport_AbstractSmtpTransport","type":"->"},{"file":"/usr/share/webapps/nextcloud/lib/private/Mail/Mailer.php","line":204,"function":"send","class":"Swift_Mailer","type":"->"},{"file":"/usr/share/webapps/nextcloud/apps/settings/lib/Mailer/NewUserMailHelper.php","line":174,"function":"send","class":"OC\\Mail\\Mailer","type":"->"},{"file":"/usr/share/webapps/nextcloud/apps/provisioning_api/lib/Controller/UsersController.php","line":342,"function":"sendMail","class":"OCA\\Settings\\Mailer\\NewUserMailHelper","type":"->"},{"file":"/usr/share/webapps/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":170,"function":"addUser","class":"OCA\\Provisioning_API\\Controller\\UsersController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/share/webapps/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/share/webapps/nextcloud/lib/private/AppFramework/App.php","line":137,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/share/webapps/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->"},{"file":"/usr/share/webapps/nextcloud/lib/private/Route/Router.php","line":297,"function":"call_user_func"},{"file":"/usr/share/webapps/nextcloud/ocs/v1.php","line":88,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/usr/share/webapps/nextcloud/ocs/v2.php","line":24,"args":["/usr/share/webapps/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/usr/share/webapps/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php","Line":269,"CustomMessage":"Unable to send the invitation mail to matthias.braun@liwest.at"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0","version":"19.0.1.1"}
{"reqId":"dg5hGPKGBbLJgLZxs3lz","level":3,"time":"2020-08-13T10:45:34+00:00","remoteAddr":"2001:871:23c:8a:9972:ca13:9d14:6243","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav","message":"session_start(): A session had already been started - ignoring at /usr/share/webapps/nextcloud/lib/private/Session/Internal.php#209","userAgent":"DAVx5/3.2.1.3-ose (2020/07/28; dav4jvm; okhttp/4.8.0) Android/8.1.0","version":"19.0.1.1"}

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

<?php
$CONFIG = array (
  'instanceid' => 'oc99wohs1ub5',
  'passwordsalt' => 'salty',
  'secret' => 'very',
  'trusted_domains' =>
  array (
    0 => 'cloud.mb.sb',
  ),
  'datadirectory' => '/usr/share/webapps/nextcloud/data',
  'dbtype' => 'pgsql',
  'version' => '19.0.3.1',
  'overwrite.cli.url' => 'https://cloud.mb.sb',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => 'very secret',
  'installed' => true,
  'log_type' => 'file',
  'logfile' => '/usr/share/webapps/nextcloud/logs/log',
  'logfilemode' => 416,
  'loglevel' => '1',
  'logdateformat' => 'F d, Y H:i:s',
  'theme' => '',
  'maintenance' => false,
);

Please let me know how to debug this further.

This wasn’t the fault of the Nextcloud app in any way. After a server reboot, some old iptables rules came active again which caused the issue. I removed the problematic iptables rules (port redirects) and made the changes permanent with “iptables-save -f /etc/iptables/iptables.rules”.

I assume caching is the reason why Nextcloud Talk still worked.