External access not working

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 18.0.2): 19.0.0.12
Operating system and version (eg, Ubuntu 20.04): DietPi 6.31.2
Apache or nginx version (eg, Apache 2.4.25): lighttpd (version unknown)
PHP version (eg, 7.1): 7.3

The issue you are facing:
Nextcloud is working fine on internal connections, but doesn’t seem to work on external. I set up port forwarding on a previous attempt to get this going using an unbundled set up and that worked okay, but it was using a minimal amount of ram (I have a Pi4/8GB) and was slow. Further research uncovered Nextcloud on DietPi that implemented caching (much quicker) and was fully set up. The port forwarding and Duckdns side is working fine, but I am getting Connection Refused errors in browsers.

The command line methods (there are multiple on the page - are any of them correct?) all come back with “command not found”. (Later found that it isn’t a NextcloudPi install but DietPi’s optimized package.)
The webui (192.168.0.5:4443) comes back with Connection Refused (same error as trying to access from outside).

As mentioned previously, the Nextcloud stuff itself (can make/remove users, upload & preview files etc.) is working, it is just the access to the config and from external locations that aren’t. (And is the wiki documentation correct?)

Is this the first time you’ve seen this error? (Y/N): Yes - new installation

Steps to replicate it:

  1. Try to access from outside of the LAN

The output of your Nextcloud log in Admin > Logging:

I suspect irrelevant but:
Error	PHP	session_start(): A session had already been started - ignoring at /var/www/nextcloud/lib/private/Session/Internal.php#209		2020-07-09T18:53:40+0100
Error	PHP	Undefined index: debugMode at /var/www/nextcloud/core/templates/exception.php#26		2020-07-09T12:33:47+0100
Error	PHP	Undefined index: debugMode at /var/www/nextcloud/core/templates/exception.php#17		2020-07-09T12:33:47+0100
Fatal	webdav	Sabre\DAV\Exception\RequestedRangeNotSatisfiable: The start offset (0) exceeded the size of the entity (-2038665976)		2020-07-09T12:33:47+0100
Error	PHP	Undefined index: debugMode at /var/www/nextcloud/core/templates/exception.php#26		2020-07-09T12:33:37+0100
Error	PHP	Undefined index: debugMode at /var/www/nextcloud/core/templates/exception.php#17		2020-07-09T12:33:37+0100
Fatal	webdav	Sabre\DAV\Exception\RequestedRangeNotSatisfiable: The start offset (0) exceeded the size of the entity (-2038665976)		2020-07-09T12:33:37+0100
Error	PHP	file_put_contents(): content truncated from 2256301320 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#555		2020-07-09T12:30:11+0100
Error	PHP	file_put_contents(): content truncated from 2257065241 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#555		2020-07-09T12:30:07+0100
Error	PHP	file_put_contents(): content truncated from 2256301320 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#555		2020-07-09T12:05:46+0100
Error	PHP	file_put_contents(): content truncated from 2257065241 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#555		2020-07-09T12:05:38+0100
Error	PHP	session_start(): A session had already been started - ignoring at /var/www/nextcloud/lib/private/Session/Internal.php#209		2020-07-09T11:47:58+0100
Error	ocs_api	Swift_TransportException: 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)		2020-07-09T11:47:29+0100
Fatal	ocs_api	Failed addUser attempt: User already exists.		2020-07-09T11:47:27+0100
Fatal	ocs_api	Failed addUser attempt: User already exists.		2020-07-09T11:44:14+0100
Error	index	OCP\Files\NotPermittedException: Could not create folder		2020-07-09T11:14:44+0100
Error	index	OCP\Files\NotPermittedException: Could not create folder		2020-07-09T11:14:44+0100
Error	index	OCP\Files\NotPermittedException: Could not create folder		2020-07-09T11:14:44+0100
Warning	appstoreFetcher	Could not connect to appstore: cURL error 28: Operation timed out after 10000 milliseconds with 1146890 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)		2020-07-09T11:10:16+0100

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

$CONFIG = array (
  'passwordsalt' => '[PASSWORD STUFF]',
  'secret' => '[SECRET STUFF]',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'colinrnas.duckdns.org',
    2 => '*',
  ),
  'datadirectory' => '/mnt/dietpi_userdata/nextcloud_data',
  'dbtype' => 'mysql',
  'version' => '19.0.0.12',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
  ),
  'overwrite.cli.url' => 'http://localhost/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '[USERNAME]',
  'dbpassword' => '[PASSWORD]',
  'installed' => true,
  'instanceid' => '[INSTANCE]',
  'maintenance' => false,
);

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

No sign of Apache/nginx but I do have a lighttpd directory containing error.log which is empty.

Access to ncp-web:4443 is restricted in
/etc/apache2/sites-enabled/ncp.conf
Although one is advised for security reasons not to allow access from outside (safer to use ssh and ncp-config), for testing purpose on VPS, I have added a ligne with my home IP address to the RequireAny section in that file. Reload apache required to take effect.
for general ref https://docs.nextcloudpi.com/en/

It was throwing out the same error (ERR Connection refused) for ncp-web:4443 (from an internal address) as it was for trying to access from the outside world, so thought they may be related issues (or at least on neighbouring lines in a config file somewhere). I won’t need to access ncp-web from outside once it is all set up - it will be sitting on a shelf next to a switch at home and I may be on holiday uploading scuba diving video footage to it for later editing in case my cheap crappy travel laptop dies/doesn’t make it home.

I would use ncp-config over ssh, but it isn’t working either (command not found).

No apache2 (lighttpd instead)… no ncp-config… guessing this isn’t actually ncp but a curated package of the original nc provided in the DietPi catalogue. I’m barking up the wrong tree I think. More reading required. It runs really quickly so I want to get this install fixed rather than start yet again.