Nextcloud Connection Wizard - ERR_CONNECTION_REFUSED

snap
nginx
desktop

#1

Hi,

I did my first install of Nextcloud server today using the Snap installation method on Ubuntu 18.04. I configured the server to use its own subdomain with a certificate from LetsEncrypt and everything is working fine when accessed in the browser.

The only slightly non-standard thing about my configuration is that I’m using nginx as a proxy to split requests (based on domain) between different web servers (The Nextcloud Apache server being one) running on different ports. So nginx was configured to forward requests to Apache and then I used certbot to automatically configure nginx with my SSL certificate. And as I said, everything loads fine in web browsers on multiple desktop machines.

The problem I’m having is that the desktop client (on both Mac and Linux) is failing to log in to my server.

STR:

  • Start new account wizard
  • Enter server address
  • Click “Next”
  • (login flow web interface loads successfully from server)
  • Click “Log in”

Expected:

  • Prompted for login by server

Actual:

This site can’t be reached

localhost refused to connect

ERR_CONNECTION_REFUSED

It looks like the wizard has for some reason tried to load a page from localhost for this step rather than my server’s domain.

What am I doing wrong?

Thanks


#2

Update: Same problem on Android app.


#3

Upon further research I’ve reached the conclusion that Nextcloud is failing to automatically detect its hostname and so was generating URLs using localhost. I’ve managed to fix this by manually overriding the host and protocol.

$ sudo nextcloud.occ config:system:set overwritehost --value="mydomain.com"
$ nextcloud.occ config:system:set overwriteprotocol --value="https"

Unfortunately a side effect of this is that I can no longer use Nextcloud using its local IP address or hostname (e.g. if the Internet goes down) because it always redirects to the public domain.