Cannot add ftp storage

Hi community,

i get the following error when i try to add my ftp storage (fritzbox):

ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known at [...]apps/files_external/lib/Lib/Storage/FtpConnection.php#37

The ftp server is reachable via the command prompt on my server.
I use nextcloud 23.0.5 on ubuntu 20.04 with apache 2.4.41 and php 7.4.3

Can anyone help me?


Hi @caveflow

Ist the the required PHP module installed on your server?

sudo apt install php-ftp

Hi @bb77

thanks for your answer.

Note, selecting 'php7.4-common' instead of 'php-ftp'
php7.4-common is already the newest version (7.4.3-4ubuntu2.10).

php7.4-common is installed, which seems to contain the php-ftp package.


Hmm not sure then what causes this. Here a few ideas…

  • You are using a hostname and DNS resoultion is not working. In this case you could try to using the IP address instead of the DNS name.
  • The path respective the folder names do not match.
  • You did specify the protocol in the “Host” field of the External Storage app like this: (ftp://IP-ADDRESS). Try to enter just the hosname or the IP address. Otherwise it’s probably doubeling it up, because the app already adds ftp:// to the URL automatically.
  • Something else I didn’t think of. Unfortunately, this is a rather generic error message.

If none of this works, maybe you could post screenshots of your configs from both the FritzBox and the External Storage app in Nextcloud…

Read this thread.

  • Do not type in ftp://xxx but only the server domain or IP
  • You have to add the port by “:21” e.g.

Or do you use TLS/SSL FTP?
Do do you use sftp instead of FTP(S) :wink:

thanks for your help.

  • I also tried the IP address - without success.
  • I try to connect via ftp (not ftps or sftp).
  • I specify only the hostname (without ftp://) in the form ‘hostname:port’.

Here are some screenshots:

The exclamation mark (error) in the nextcloud external storage config appears immediately (without delay), so maybe there are missing permissions to establish the ftp_connect() function?

I think ftps:// is wrong. Read this documentation. Please post then new screenshots. Please blacken only your domain and the TLD and port.

I’m sorry, but I don’t understand what you mean by that.
Where do you see ftps? I just use ftp


Ok sorry. I think ftp:// is wrong. In this documentation the example is (bad example the default port is 21) and not

Okay, but thats what i use:

Because of fritz...4 i think it is not FTP. Please explain your settings. If it is your Fritzbox and you use Nextlcoud at home you must set the FTP relative to your Nextcloud e.g. ftp-internal-ip:21.

Please explain your settings.

  • Where is your Nextcloud?
  • Where is your FTP-Server?
  • Do you use a Fritzbox?

My nextcloud runs on a separate VPS and is reachable via the internet.
My ftp-server is a fritzbox, which is reachable via DDNS (thats why it begins with fritz…) via the internet. I changed the default port to 4…

I can connect the the ftp-server directly from the server where the nextcloud runs.

There is also no problem to connect to the fritzbox-ftp-server via other clients/machines - just nextcloud can not connect.

I don’t use niether a FritzBox nor FTP but I found this… (German)

In this tutorial port 47891 is used on the Fritzbox and as far as I can tell @caveflow is doing everything right on the Nextcloud side. What I don’t know is whether the External Storage App supports non default ports.

@caveflow Maybe you can try to set the FTP server to port 21 on the Fritzbox and see if it works without specifying a port in the External Storage App.


Ok i looked again your screenshots and all was clear with Fritzbox, …
Maybe you can temporary use the standard FTP port to narrow down the error.

1 Like

I changed the server port to 21 and now it works!

Thank you so much - i really appriciate that.


so If I configure my FTP server to use port 2121 , and tell nextcloud to use port 2121, does this mean that I can not overwrite the port?

this was working for me and it broke recently

Maybe this issue on GitHub is of any help… [Bug]: after upgrade NC to 23.0.2 app external storage support stops working · Issue #31510 · nextcloud/server · GitHub

You can ip:port (see network socket) at the same time only once. If you first start e.g. FTP server on ip (or a name) on port 2121 and then apache2 on ip (or the same name) on port 2121 the socket (ip:port or name:port) is already used and apache2 does not work.

I added “port” on setting page.

file - html/apps/files_external/lib/Lib/Backend/FTP.php

                            new DefinitionParameter('host', $l->t('Host')),
                            (new DefinitionParameter('port', $l->t('Port')))
                            (new DefinitionParameter('root', $l->t('Remote subfolder')))
                            (new DefinitionParameter('secure', $l->t('Secure ftps://')))

Thats working great (on v23.0.12). @caveflow should considerer as a solution to implement. Thanks Nikolay.