Can't access the nextcloudpi server outside local network

Thanks to all in advance and I hope for your support.

Nextcloud version :
Operating system and version Debian GNU/Linux 10 (buster)
Apache or nginx version : 2.4.38
PHP version : 7.3.27

Hello, I’ve succesfully setup a Nextcloud server from NextcloudPi image, and I am trying to setup access to my Nextcloud server running on my Raspberry Pi 3B outside my local network. I am using Namecheap as my domain register and Dynamic DNS provider.

So far I’ve:

Running netstat -lntu shows :

tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 :::25                   :::*                    LISTEN     
tcp6       0      0 :::4443                 :::*                    LISTEN     
tcp6       0      0 :::443                  :::*                    LISTEN
  • Ran a namecheapDNS command from my control panel with no errors shown
  • I can also succesfully ping the domain name

But I am still unable to connect to my server using the domain name, the connection is timed out.

It is my first time trying to this sort of thing, so any advice or suggestion on how to narrow down the problem or what is causing it would be great. Thanks :slight_smile:

A quick thought (I’ve not used NexcloudPi), but is there a firewall enabled? Can you connect to the webserver on the Pi from inside the network? Either by IP address (which will complain horribly about incorrect hostname, probably) or by setting up some means of locally resolving the domain name?

I spent a chunk of time one day trying to work out why I couldn’t connect to Nextcloud on a VM. I’d forgotten to add a firewall rule in to allow the traffic through the host machine :slight_smile:

Yes, I forgot to mention, I can connect to a server from inside my local network using an IP address and by SSH. It’s that I want to be able to use it outside my local network also.

Some more things to attempt… Try connecting from inside and outside of the network - I’ve also had some weird routing issues, but that may be because I’m resolving the domain name locally. Occasionally a client picks up an odd external IP address and then fails. Or resolves to the web interface of the firewall, which refuses to talk to an external IP address.

Other things to check:

  • Does the ping command resolve the correct IP address? Again, you should try from internally and externally.
  • Is the webserver set to answer to all IPs and names, or just the internal IP address?
  • I don’t think it’s relevant (yet) as you’re timing out, but have you looked at the Trusted Domain config?

Other than that, I think that someone else would need to answer as I’ve not got the experience of your setup. Mine runs on a VM inside my network, resolving to a real domain name, but is never used externally as I VPN into my network. I just have weird routing issues occasionally, as mentioned before.

If I ping my registered domain name it resolves to a namecheap IP address, and not of my RPi, but I thought that’s what is supposed to happen, as I have no static IP and have to use dynamic DNS service. I can ping my RPi locally no problem. Its IP is, obviously, local. I’ve looked at trusted-domain config and there was also no problem.

My suggestion is that the connection is dropped somewhere between the namecheap server and my RPi, and two candidates are my router and my ISP. How can I check where the connection is lost?

Can you (locally) run curl then do dig <your domain name> remotely and see if the IP’s match

If you are using Dynamic DNS, it should resolve to whatever your external IP address is - that’s the point of it - the idea is that it keeps track of your IP address when it changes.

From inside your network, find out your external IP address (search what’s my IP and either use one of the sites, or your search engine might tell you). Try that IP address to see if you can connect.

First of all you should try if you can connect to nextcloud from external via your current external ip, if not, it could be that you have a pooled (NATed) ip address from your provider. If this is the case, you could probably be f…ed…
If you ping your url it should resolve to your external ip address, not your pi’s local ip.

running dig shows two positions, the latter one with IP address of my RPi server

I can not connect to my nextcloud server, and when I ping it’s IP I get nothing, no responce whatsoever.

I suspect I have a pooled IP address, as I am using mobile data (4G), it’s my only option, no wired ISP want to get me connected.

Is there any possibility to connect to my nextcloud server outside local network then? I don’t really care about domain name, I just want to host nextcloud locally.

You can not ping your server directly from the internet using its local ip, you can only ping your modem and that would need to forward port 80 and 443 to the server. This has to be configured on the modem in port forwarding. But this only works if the modem is connected directly to the internet with its own ip, if you are pooled you have no controll of the device managing the ip-pool.
You can check if you are pooled by comparing your modems wan ip with the result of If these differe you are pooled.

However, there is a way to get this working, either contact your isp and tell him that you need to connect to some iot device in your network from outside the house, you dont care about a fixed ip, but you need one that can be reached from outside. Or you could make your server build a wireguard tunnel to a device that is visible to the internet and make that forward port 80 and 443 to your server, but this means to rent a dedicated server on the internet to access your cloud at home.

The Namecheap guide shows setup for a dynamic IPv4 addresses only. Namecheap only supports IPv4 as stated on the page. But your netstat output only shows IPv6 services.
Doesn’t the server have an IPv4 configuration?