Nextcloud acessable through IP, but not Domain


I have Nextcloud running on my Debian Server using apache2.

I have the problem, that Nextcloud is accessible with the server ip, but not with the domain (A Name). There’s the default apache page.
I’ve added the domain to the trusted domains, but has not helped.!
IP- Adress:


Anyone a idea?

have you checked your settings for apache? you can set there whether it should bind/listen to a specific address. And don’t forget to restart the service after you changed some settings (i have made this mistake and searched hours why apache wasn’t the way working it supposed to work :sweat_smile::joy:)

I’ve checked them but have not found something. Maybe someone has an idea.
I’ve restarted the service!

maybe you can post your configuration here (of course change domains etc. to something neutral)? Especially your configuration for your virtual host would be interesting to know :slight_smile:

Here my config:

Hope someone can help.

the config for Nextcloud seems alright, but i meant the configuration for your virtual host in apache. For example mine looks like this:

#    ServerAdmin
#    ServerName
#    ServerAlias

### SETTINGS ###
    <FilesMatch "\.php$">
        SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"

    DocumentRoot /var/www/nextcloud

    <Directory /var/www/nextcloud>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    Satisfy Any

    <IfModule mod_dav.c>
    Dav off

    <Directory "/mnt/ncdata">
    # just in case if .htaccess gets disabled
    Require all denied
    # The following lines prevent .htaccess and .htpasswd files from being
    # viewed by Web clients.
    <Files ".ht*">
    Require all denied
    # Disable HTTP TRACE method.
    TraceEnable off

    # Disable HTTP TRACK method.
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} ^TRACK
    RewriteRule .* - [R=405,L]

    SetEnv HOME /var/www/nextcloud
    SetEnv HTTP_HOME /var/www/nextcloud

You can easily edit this with Webmin (not something for hardcore Linux fans but I like it) or by editing the config file with the Terminal at /etc/apache2/sites-available (
In my config for the Virtual Host I tell the server to listen to the IP, but you can change that to listen to every address by replacing the address with a *

Oh sorry, my fault:

ok, my first guess would be to change the ServerName to your domain (, it looks like you are using an IP. I’m no expert for apache but this could be the reason why its only working when you type in the IP

Yeah, I’ve tried this but then the domain AND the IP does not work.

second thoughts, are you using apache as a proxy? Is this for
Otherwise you need to make sure that your domain resolves to your IP (maybe add in /etc/hosts?)

I have not set apache as a proxy.

This is /etc/hosts:
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters localhost.localdomain localhost

Auto-generated hostname. Please do not remove this comment.

62.XXX.XXX.XX cloud.XXX-de srv01
::1 localhost ip6-localhost ip6-loopback

And the problem is, there is the default page when accesing throug the domain.
Would there be “Server not available” it would be much easier

When you use your domain, it opens /var/www/html/index.html
When you use your ip, it opens /var/www/nextcloud/index.php
(according to the info you gave)

You have to look for a conffile where documentroot is set to /var/www/html. Change it to /var/www/nextcloud
I’m not Apache expert either…

@MeiRos good idea, maybe there is a virtual host where this other documentroot is set. Although the config @max18 has given looks right and it is listening to all adresses. It seems strange to me when apache is choosing an other virtual host/and other documentroot for the domain

EDIT: maybe there is one configured especially for the domain, that would make sense

Thanks, that solved the problem. Had to modify the documentroot.

Thanks to all that participated!

One other question:
How can i add a second v host?
For example, Nextcloud on port 80 and a other webserver (impressum…) on port 81. NOW i need the default page on this port xD

just add another apache config file with something like this

<VirtualHost *:81>

### SETTINGS ###

    DocumentRoot /var/www/html

    <Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    Satisfy Any

but I would rather specify a virtual directory, because this would be reachable on Port 80/443, so this solution would look a lot better

Added the file imp.conf, with my parameters.
Restarted apache, but browser says website not found.

I would check the DNS settings of the domain.