That is often a problem with your DNS server. You can measure the time to see if it is really the nameserver which delays the process:
Is this your own server? You could install your own DNS resolver which is probably faster and caches entries. Unbound is a very small light-weight solution.
12:04:55.964641 * Trying 174.129.145.xxx...
12:07:03.252478 * connect to 174.129.145.xxx port PORT failed: Connection timed out
12:07:03.252723 * Failed to connect to DOMAIN port PORT: Connection timed out
12:07:03.252778 * Closing connection 0
curl: (7) Failed to connect to DOMAIN port PORT: Connection timed out
It’s not your DNS. In your case the connection cannot be opened. A firewall is very likely the cause of this. So if your friend is behind a router, you need to forward the port of his setup (on his router). Can you open his webinterface on your browser?
But I think, we found the issue: My NC-server has a DNS problem. It gets always other (wrong) IPs for the domain of my friend. Not so on another client in my network here behind my Fritz!Box.
DNS entries are usually cached for some time. In Ubuntu you can flush the cache: sudo /etc/init.d/dns-clean
You FritzBox-DNS could cache them as well (and the DNS server your FritzBox gets the entry from).
As a temporary solution (until the DNS is fixed and all caches are cleared, ~1 day), you can edit your /etc/hosts-file and put there: a.b.c.d your.friend.com
a.b.c.d is the ip address, and your.friend.com the hostname.
So, I’m the guy at the other side of this test.
While @hustenfrei got it to work with the /etc/hosts workaround and he successfully got my shared folder, I’m unable to see his shared folder. No notification in Nextcloud for me. But I can see the following error in my logfile:
Exception: {“Message”:“HTTP/1.1 401 No ‘Authorization: Basic’ header
found. Either the client didn’t send one, or the server is
mis-configured”,“Exception”:“Sabre\DAV\Exception\NotAuthenticated”,“Code”:0,“Trace”:"#0
[internal function]:
Sabre\DAV\Auth\Plugin->beforeMethod(Object(Sabre\HTTP\Request),
Object(Sabre\HTTP\Response))\n#1
/var/www/localhost/htdocs/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php(105):
call_user_func_array(Array, Array)\n#2
/var/www/localhost/htdocs/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php(446):
Sabre\Event\EventEmitter->emit(‘beforeMethod’, Array)\n#3
/var/www/localhost/htdocs/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php(248):
Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request),
Object(Sabre\HTTP\Response))\n#4
/var/www/localhost/htdocs/nextcloud/apps/dav/appinfo/v1/webdav.php(55):
Sabre\DAV\Server->exec()\n#5
/var/www/localhost/htdocs/nextcloud/remote.php(138):
require_once(’/var/www/localh…’)\n#6
{main}",“File”:"/var/www/localhost/htdocs/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php",“Line”:188,“User”:false}
Searching the web for the error, it seems like a problem with PHP7,.but to my knowledge Nextcloud should work with PHP7.
I successfully added his Server to my trusted Nextcloud-Servers and also I successfully was able to share one of my folders with him.