# External Storage via FTP over SSL not working with port number

**URL:** <https://help.nextcloud.com/t/external-storage-via-ftp-over-ssl-not-working-with-port-number/170626>\
**Category:** ℹ️ Support\
**Tags:** external\_storage, ftp\
**Created:** [September 21, 2023, 9:01am UTC](https://help.nextcloud.com/t/external-storage-via-ftp-over-ssl-not-working-with-port-number/170626 "2023-09-21T09:01:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Athapatchinie](https://help.nextcloud.com/letter_avatar/athapatchinie/32/6_22734026db12803ebb3e059622ac3534.png) [@Athapatchinie](https://help.nextcloud.com/u/Athapatchinie)\
**Post date:** [September 21, 2023, 9:01am UTC](https://help.nextcloud.com/t/external-storage-via-ftp-over-ssl-not-working-with-port-number/170626/1 "2023-09-21T09:01:23Z")

</div>

I’m running 27.1.0 and I’m trying to add external storage via FTP over SSL which gives me the following error:  
“ftp\_ssl\_connect(): php\_network\_getaddresses: getaddrinfo for [SERVER.COM](http://SERVER.COM):PORT failed: Name or service not known”

Without port numbers, it works (technically, but not really in my case, I need that specific port).

What I found out and what I assume is the problem:  
When I ssh into the server and type “ftp [server.com](http://server.com):port” I get the same message – “Name or service not known”

When I use “ftp [server.com](http://server.com) port” however, I get the connection.

So now I’m wondering what to do with my very basic coding skills. Can I change a line of code somewhere so that my NC installation will use the ftp command without colon?

I hope someone can help! 🙂

---

<div class="post-metadata">

**Author:** ![Athapatchinie](https://help.nextcloud.com/letter_avatar/athapatchinie/32/6_22734026db12803ebb3e059622ac3534.png) [@Athapatchinie](https://help.nextcloud.com/u/Athapatchinie)\
**Post date:** [September 22, 2023, 10:12am UTC](https://help.nextcloud.com/t/external-storage-via-ftp-over-ssl-not-working-with-port-number/170626/2 "2023-09-22T10:12:45Z")

</div>

I found a solution!

> <https://github.com/nextcloud/server/issues/32773#issuecomment-1412538302>
>
> \### ⚠️ This issue respects the following points: ⚠️
> 
> \- \[X\] This is a \*\*bug\*\*, no…t a question or a configuration/webserver/proxy issue.
> \- \[X\] This issue is \*\*not\*\* already reported on Github \_(I've searched it)\_.
> \- \[X\] Nextcloud Server \*\*is\*\* up to date. See \[Maintenance and Release Schedule\](https://github.com/nextcloud/server/wiki/Maintenance-and-Release-Schedule) for supported versions.
> \- \[X\] I agree to follow Nextcloud's \[Code of Conduct\](https://nextcloud.com/contribute/code-of-conduct/).
> 
> \### Bug description
> 
> Attempting to use an external FTP storage with a non-standard port fails. This is due to FtpConnection:\_\_construct() getting the port to use from the GUI as part of the hostname argument and using the raw value as is. While PHP's ftp connect functions expect the hostname and port to be separate arguments.
> 
> This can also be seen in the cli:
> $sudo php ./occ files\_external:config mount id hostname
> example.com:1234
> $sudo php ./occ files\_external:config mount id port
> null
> $
> 
> This will cause the debug log to get a PHP error from either ftp\_ssl\_connect() or ftp\_connect(): getaddrinfo failed: Name or service not known
> 
> \### Steps to reproduce
> 
> 1. Enable external storage support.
> 2. Add a new FTP or FTPS external storage configuration.
> 3. Specify the non-standard port in the host box \[as per the instructions in the admin manual\](https://docs.nextcloud.com/server/latest/admin\_manual/configuration\_files/external\_storage/ftp.html).
> 4. Attempt to test the connection.
> 
> 
> \### Expected behavior
> 
> FTP connection test to succeed and the external storage to be usable.
> 
> \### Installation method
> 
> Manual installation
> 
> \### Operating system
> 
> Debian/Ubuntu
> 
> \### PHP engine version
> 
> PHP 7.4
> 
> \### Web server
> 
> Apache (supported)
> 
> \### Database engine version
> 
> MariaDB
> 
> \### Is this bug present after an update or on a fresh install?
> 
> Updated from a minor version (ex. 22.2.3 to 22.2.4)
> 
> \### Are you using the Nextcloud Server Encryption module?
> 
> Encryption is Disabled
> 
> \### What user-backends are you using?
> 
> \- \[\] Default user-backend \_(database)\_
> \- \[X\] LDAP/ Active Directory
> \- \[\] SSO - SAML
> \- \[\] Other
> 
> \### Configuration report
> 
> \_No response\_
> 
> \### List of activated Apps
> 
> \`\`\`shell
> Enabled:
> - accessibility: 1.9.0
> - activity: 2.15.0
> - bruteforcesettings: 2.4.0
> - calendar: 3.3.1
> - circles: 23.1.1
> - cloud\_federation\_api: 1.6.0
> - comments: 1.13.0
> - contacts: 4.1.1
> - contactsinteraction: 1.4.0
> - dashboard: 7.3.0
> - dav: 1.21.0
> - deck: 1.6.1
> - federatedfilesharing: 1.13.0
> - federation: 1.13.0
> - files: 1.18.0
> - files\_accesscontrol: 1.13.0
> - files\_automatedtagging: 1.13.0
> - files\_external: 1.15.0
> - files\_pdfviewer: 2.4.0
> - files\_rightclick: 1.2.0
> - files\_sharing: 1.15.0
> - files\_trashbin: 1.13.0
> - files\_versions: 1.16.0
> - files\_videoplayer: 1.12.0
> - firstrunwizard: 2.12.0
> - groupfolders: 11.1.4
> - impersonate: 1.10.0
> - logreader: 2.8.0
> - lookup\_server\_connector: 1.11.0
> - mail: 1.13.1
> - nextcloud\_announcements: 1.12.0
> - notifications: 2.11.1
> - oauth2: 1.11.0
> - password\_policy: 1.13.0
> - photos: 1.5.0
> - privacy: 1.7.0
> - provisioning\_api: 1.13.0
> - recommendations: 1.2.0
> - richdocuments: 5.0.5
> - richdocumentscode: 21.11.402
> - serverinfo: 1.13.0
> - settings: 1.5.0
> - sharebymail: 1.13.0
> - support: 1.6.0
> - survey\_client: 1.11.0
> - systemtags: 1.13.0
> - text: 3.4.1
> - theming: 1.14.0
> - twofactor\_backupcodes: 1.12.0
> - updatenotification: 1.13.0
> - user\_ldap: 1.13.1
> - user\_status: 1.3.1
> - viewer: 1.7.0
> - weather\_status: 1.3.0
> - workflowengine: 2.5.0
> Disabled:
> - admin\_audit
> - encryption
> - spreed: 13.0.4
> \`\`\`
> 
> 
> \### Nextcloud Signing status
> 
> \_No response\_
> 
> \### Nextcloud Logs
> 
> \`\`\`shell
> {"reqId":"NsjKBrLbJjZB15Pp3E28","level":3,"time":"2022-06-09T02:01:43+00:00","remoteAddr":"192.168.1.3","user":"27743958-36BD-4C10-9F27-FD772916DFCC","app":"PHP","method":"GET","url":"/index.php/apps/files\_external/globalstorages/5?testOnly=true","message":"ftp\_ssl\_connect(): php\_network\_getaddresses: getaddrinfo failed: Name or service not known at /local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/Lib/Storage/FtpConnection.php#35","userAgent":"Mozilla/5.0 (X11; Linux x86\_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36","version":"23.0.5.1","exception":{"Exception":"Error","Message":"ftp\_ssl\_connect(): php\_network\_getaddresses: getaddrinfo failed: Name or service not known at /local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/Lib/Storage/FtpConnection.php#35","Code":0,"Trace":\[{"function":"onError","class":"OC\\\\Log\\\\ErrorHandler","type":"::"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/Lib/Storage/FtpConnection.php","line":35,"function":"ftp\_ssl\_connect"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/Lib/Storage/FTP.php","line":81,"function":"\_\_construct","class":"OCA\\\\Files\_External\\\\Lib\\\\Storage\\\\FtpConnection","type":"-\>"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/Lib/Storage/FTP.php","line":189,"function":"getConnection","class":"OCA\\\\Files\_External\\\\Lib\\\\Storage\\\\FTP","type":"-\>"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/MountConfig.php","line":130,"function":"test","class":"OCA\\\\Files\_External\\\\Lib\\\\Storage\\\\FTP","type":"-\>"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/Controller/StoragesController.php","line":288,"function":"getBackendStatus","class":"OCA\\\\Files\_External\\\\MountConfig","type":"::","args":\["\*\*\* sensitive parameters replaced \*\*\*"\]},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/apps/files\_external/lib/Controller/StoragesController.php","line":363,"function":"updateStorageStatus","class":"OCA\\\\Files\_External\\\\Controller\\\\StoragesController","type":"-\>","args":\["\*\*\* sensitive parameters replaced \*\*\*"\]},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"show","class":"OCA\\\\Files\_External\\\\Controller\\\\StoragesController","type":"-\>"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\\\AppFramework\\\\Http\\\\Dispatcher","type":"-\>"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\\\AppFramework\\\\Http\\\\Dispatcher","type":"-\>"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\\\AppFramework\\\\App","type":"::"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\\\Route\\\\Router","type":"-\>"},{"file":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}\],"File":"/local\_data/Manually\_Installed/Web\_Applications/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"62a1548869b19"}
> \`\`\`
> 
> 
> \### Additional info
> 
> As a workaround, manually setting the port for the external storage via the occ command on the CLI will allow the connection to work.
> E.x.
> $sudo php ./occ files\_external:config mount\_id host example.com
> $sudo php ./occ files\_external:config mount\_id port 1234

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 14, 2024, 1:04pm UTC](https://help.nextcloud.com/t/external-storage-via-ftp-over-ssl-not-working-with-port-number/170626/3 "2024-12-14T13:04:40Z")

</div>


