Nextcloud installation: Error while trying to create admin user

I am trying to install NC 12 on a Synology DS 216j with Apache 2.2, PHP 5.6, MariaDB 10 following this guide:

After starting the setup I get the following message:
Error while trying to create admin user: Failed to connect to the database: An exception occured in driver:
SQLSTATE[HY000][2002] No such file or directory

Any idea? Thank you very much for your help.

umm… good plan to have your data at home. so welcome to nc!

your error reads to me as if there’s a problem with your database. does it really exist?

Thank you. Problem is solved (MySQL bind only allows as address and MariaDB listens to port 3307)

Yes. Just type in “” at “localhost”. That’s the solve! Thanks alot!

1 Like

If you use the nextcloud docker image, you need to enter just “db” as hostname.



Jesus, I’ve been trying to get this working for hours, and this worked. I wish it was better documented.

I tried with typing it but still it shows connection refused and I created docker image with localhost:8065

Check @rubo77 answer for docker.

Use db as a hostname for the docker or check your docker-compose.yml file to see the database service name and use this service name as a hostname.

1 Like

Thank you !

Well, this was useful. Whatever the reason, localhost:3307 wopuld not work, while did work… Thanks!

Thank you! I know I’m 2 years late to the party but your reply sorted my issue!

I agree with the other poster, the official documentation should explain this better.

It is explained there, How could we enhance the documentation? where did you expect that information elsewhere?

OK, thank you. I hold my hands up the information is there and I missed it!

My suggestion, for noobs like me, would be to lay out the information in the order that the set up screen requests the information as it may be a little simpler to understand.

Thank you so much rubo77 you helped me a lot and this worked!


I have used nextcloud with docker along with nextcloud, mariadb and swag some weeks for now.
Yesterday I pulled the newest image of nextcloud with the tag latest.
Then there always was an internal server error and I wasn’t able to connect to nextcloud any more.
I tried the whole day to get it to work. Nothing.
Then I decided to install all new.
I have deleted all the volumes and installed everything from the beginning.
Now, I am not able to create an user account any more.

Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again

As localhost I defined the name of the docker image of the db, which is nextclouddb in my case.
It doesn’t work any more.

I have searched the internet and I think this is not a specific error of nextcloud, it is an php problem, but I don’t know how to solve it…

1 Like

Thank you @Dominik-1980
I have the same issue, i’ve searched everywhere but no answer to this, did you find a solution?

My nextcloud installation was part of HomeAssistant setup, where nextcloud is docker addon (installed through supervisor). Anyways, long story short what I needed to do is run docker ps and see the name of my mariadb container which in my case is addon_core_mariadb. Specifying it worked :slight_smile:

I have the exact same issue. Internal server error after an update and several things haves changed in the setup since my original install and now I’m totally lost because of this issue.