SQLSTATE[HY000] [2002] No such file or directory error on installation

Nextcloud version: 22.2.6-apache
Operating system and version: Docker (20.10.14), Ubuntu Server (20.04)
Apache or nginx version: Apache 2.4.53, Nginx Reverse Proxy (not in Docker: 1.18.0)
PHP version: 7.2

The issue you are facing:

When installing NextCloud, I recieve the following error:

Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory

I am trying to use a MySQL server which is also hosting my Wordpress sites - this server is running directly on the Ubuntu Server VM. I have created a user, password, and database for nextcloud, and have tried the following hostnames, aswell as the following with :3306 at the end. (local IP of MySQL server)
ubuntu-server (hostname)

I am unable to find logs for NextCloud - they don’t seem to have generated (I’m looking for them using Docker exec) ? So if any of you need them I would love if you can point me in the direction! The log for my reverse proxy which is pulling from a subdomain with a certificate from Cloudflare (also proxied by them) does not show anything useful.

Thank you!


this means the nextcloud docker cannot talk to the database docker…
the port 3306 is close by firewall
reverse rules are bad…

Hi @TarasZagajewski,
You are missing the required support template. Please fill this form out and edit into your post. You should be able to follow it using docker exec.

This will give us the technical info and logs needed to help you! Thanks.

Hey @just ,

Thanks for replying!

I tried to follow the last few steps of that document and still no luck. I assume Admin > Logging refers to from within the NextCloud UI? For the config.php, I cannot find that in /var/www/html; am I looking in the right place? The apache access and error logs are empty, and there is no nextcloud.log in /var/www/.

To clarify, I have not gotten past clicking install.

I’m only a couple months into using Linux in general, especially over SSH, so it could be a stupid mistake or tiny thing I’m missing. Thank you for trying to help!

@stratege1401 To respond to all of your statements:

  1. The database is not hosted in docker, but on the Ubuntu Server VM itself. My Wordpress sites whch are also on the same VM are able to access it fine, and external access (over the local network) is configured and working.

  2. I don’t believe Docker has a built-in firewall (correct me if I am wrong), and I have temporarily disabled the firewall on the host VM.

  3. I’m unsure what you mean here, do you mean the proxy? I have posted my Nginx config below.

Thank you!

server {
listen 8080;
server_name cloud.example.com;

return 301 https://$host$request_uri;

server {
listen 443 ssl http2;
server_name cloud.example.com;

client_max_body_size 10G;
client_body_buffer_size 400M;

location / {
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

# SSL parameters
ssl_certificate /etc/ssl/www.example.com.crt;
ssl_certificate_key /etc/ssl/www.example.com.key;

# log files
access_log /var/log/nginx/cloud.example.com.access.log;
error_log /var/log/nginx/cloud.example.com.error.log;