'Nextcloud (docker) fails to connect to Mysql (docker) SQLSTATE[HY000] [2002]
I have installed nextcloud with docker compose using the yaml file below
GNU nano 4.8 docker-compose.yaml
version: "3"
services:
nextcloud:
image: nextcloud:latest
restart: unless-stopped
ports:
- 8080:80
environment:
- MYSQL_HOST=mysql
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextclouduser
- MYSQL_PASSWORD=mypassword
volumes:
- nextcloud:/var/www/html
volumes:
nextcloud:
when is connect to it i fail to create an admin account with the error: 'Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution '
i have setup my database correctly (i think) when i sign in with nextclouduser i can see that the nextclouduser has access to nextcloud database
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| nextcloud |
+--------------------+
2 rows in set (0.00 sec)
Solution 1:[1]
I solved the same error while deploying docker nextcloud 23.0 by using an "older" version of mariadb :
version: '2'
volumes:
nextcloud:
db:
services:
db:
# image: mariadb:latest
image: mariadb:10.5.13
...
app:
image: nextcloud:23.0.0-apache
...
If it could help...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | r0m |
