How to access NextCloud from outside and from inside my LAN


I have installed Nextcloud 22.2.0 on Ubuntu Server 21.04 on a Raspberry Pi 4 with 8 GB of RAM.
I am using Duck DNS as DDNS.

On my Android phone, I have set up the NextCloud application with a URL like “”. This means that when I am outside my network (LAN), I can connect to NextCloud on my RPI because “” refers to the local IP address of my Raspberry Pi.
But when I connect my Android to my local network via WiFi, I can’t reach NextCloud.
When I’m connected to WiFi, “” leads me to my router’s private IP address and not to my RPI’s.
This causes a problem when I want to synchronise large files such as photos.
Apparently, I can’t register the same user account twice with two different addresses (one for when I’m outside; the other for when I want to use my WiFi.

What should I do?

Search Hairpinning or NAT Loopback for your router.

Thank you @devnull !
I enabled NAT loopback and it solved the problem.

Now when I installed NextCloud, I followed a couple of video tutorials, where it was suggested to buy a domain name in order to secure a valid SSL certificate.
But I didn’t manage to set it up.
The goal is to have a secure connection with - for example - that would point to my NextCloud setup.

Do you have any idea how to manage this?

Have you purchased a domain?

Hello @ just,

Yes, I have purchased a domain name already.
I redirected to But it’s not what I am supposed to do, is it?

I have asked some help to the registrar company where I bought the domain, but the sent me back to NextCloud.

Who is your registrar? Do they have documentation for DNS? You’ll need to setup a subdomain

You can set up a CNAME record, it just says that should resolve the same like

I bought my domain name at
Here is the documentation :

Thank you for your help @tflidd .

I am studying now to learn what a CNAME record is and how to set it up.
I don’t understand what kind of information I should input in order to have resolve like
For, I installed a script on my Ubuntu Server so the only information I have from Duck DNS is a token.

In the documentation of the registrar, I found something about LiveDNS:

Is it what I need?

You have to create a CNAME record for pointing to (, as far as I understand the documentation, you have to put a point in the end of the subdomain you want to redirect:

Yes, that is the same like the duckdns service and you can do this directly without going through duckdns. Not sure if their API is compatible with the software that you currently use.

The CNAME will certainly be faster and easier to implement. If you can do this directly with gandi without passing through duckdns is certainly a cleaner solution. I’d try that for a different subdomain first, and if it is working, you can switch the CNAME record to this method.

Thank you @tflidd !
Yes, it would be great if I could do everything with without using DuckDNS.

So far I have managed to create a CNAME record so that I can access NextCloud with And it’s not a web redirection.
So, we’re progressing !
Now, there are still a few questions:

  1. I don’t know how to change the settings on my Android NextCloud and DAVx5 apps (because now I don’t need to use anymore, do I?).
    Do I have to uninstall the apps and install them back again?
  2. Now sent me the link to this script:
    and its documentation: .
    So I am studying this. It should allow me to by-pass Duckdns.

That is a new question, please make a new topic. I don’t know if Android clients and DAVx5 support redirects and update the URL.

OK. I will look. Someone might already have met the same issue.