#✅ MariaDB and Directus issue in Docker: ECONNREFUSED

30 messages · Page 1 of 1 (latest)

soft talon
#

I get this error in Docker Logs:

2023-04-27 00:42:28 node:internal/process/promises:288
2023-04-27 00:42:28             triggerUncaughtException(err, true /* fromPromise */);
2023-04-27 00:42:28             ^
2023-04-27 00:42:28 
2023-04-27 00:42:28 Error: connect ECONNREFUSED 192.168.96.3:3306
2023-04-27 00:42:28     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
2023-04-27 00:42:28     --------------------
2023-04-27 00:42:28     at Protocol._enqueue (/directus/node_modules/.pnpm/[email protected]/node_modules/mysql/lib/protocol/Protocol.js:144:48)
2023-04-27 00:42:28     at Protocol.handshake (/directus/node_modules/.pnpm/[email protected]/node_modules/mysql/lib/protocol/Protocol.js:51:23)
2023-04-27 00:42:28     at Connection.connect (/directus/node_modules/.pnpm/[email protected]/node_modules/mysql/lib/Connection.js:116:18)
2023-04-27 00:42:28     at /directus/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/knex/lib/dialects/mysql/index.js:66:18
2023-04-27 00:42:28     at new Promise (<anonymous>)
2023-04-27 00:42:28     at Client_MySQL.acquireRawConnection (/directus/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/knex/lib/dialects/mysql/index.js:61:12)
2023-04-27 00:42:28     at create (/directus/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/knex/lib/client.js:254:39) {
2023-04-27 00:42:28   errno: -111,
2023-04-27 00:42:28   code: 'ECONNREFUSED',
2023-04-27 00:42:28   syscall: 'connect',
2023-04-27 00:42:28   address: '192.168.96.3',
2023-04-27 00:42:28   port: 3306,
2023-04-27 00:42:28   fatal: true
2023-04-27 00:42:28 }
2023-04-27 00:42:28 
2023-04-27 00:42:28 Node.js v18.16.0```

My Docker Compose File looks like this: https://pastebin.com/wbahCy3g

Where is my mistake?
mild dustBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)

turbid quiver
#

I think this sometimes happens when the db takes a longer than expected to start up. I solved this with adding
restart: on-failure
to my directus config.

There must be a better way, but this should work

soft talon
#

I have rewriten the compose file many times, i'm kinda losing my mind over this 🙈

#

i had this in it

#
      projectname-redis:
        condition: service_completed_successfully        
      projectname-mariadb:
        condition: service_completed_successfully```
#

did not help

#

thanks for the help but now direcuts is just crashing and restarting. but i also got some errors in the mariadb logs:

2023-04-27 10:41:29 This could be because you hit a bug. It is also possible that this binary
2023-04-27 10:41:29 or one of the libraries it was linked against is corrupt, improperly built,
2023-04-27 10:41:29 or misconfigured. This error can also be caused by malfunctioning hardware.
2023-04-27 10:41:29 
2023-04-27 10:41:29 To report this bug, see https://mariadb.com/kb/en/reporting-bugs
2023-04-27 10:41:29 
2023-04-27 10:41:29 We will try our best to scrape up some info that will hopefully help
2023-04-27 10:41:29 diagnose the problem, but since we have already crashed, 
2023-04-27 10:41:29 something is definitely wrong and this may fail.
2023-04-27 10:41:29 
2023-04-27 10:41:29 Server version: 10.11.2-MariaDB-1:10.11.2+maria~ubu2204 source revision: cafba8761af55ae16cc69c9b53a341340a845b36
2023-04-27 10:41:29 key_buffer_size=134217728
2023-04-27 10:41:29 read_buffer_size=131072
2023-04-27 10:41:29 max_used_connections=2
2023-04-27 10:41:29 max_threads=153
2023-04-27 10:41:29 thread_count=2
2023-04-27 10:41:29 It is possible that mysqld could use up to 
2023-04-27 10:41:29 key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 468019 K  bytes of memory
2023-04-27 10:41:29 Hope that's ok; if not, decrease some variables in the equation.
2023-04-27 10:41:29```
#

mariadb also claims to have no root password?

#
2023-04-27 10:39:56 To do so, start the server, then issue the following command:```
turbid quiver
#

For example:

environment:
      - MYSQL_DATABASE=projectname

should be

    environment:
      MYSQL_DATABASE: projectname
soft talon
#

Thanks, but I think that is the new syntax and should work interchangeably. I recreated the Docker Compose file from the Docu, without any luck.

#
services:
  database:
    container_name: database
    image: mariadb
    ports:
      - 3306:3306    
    volumes:
      - ./data:/var/lib/mysq
    networks:
      - directus
    environment:
      MYSQL_ROOT_PASSWORD: 'root_pw'
      MYSQL_DATABASE: 'db_name'
      MYSQL_USER: 'db_user'
      MYSQL_PASSWORD: 'db_user_pw'

  cache:
    container_name: cache
    image: redis:6
    networks:
      - directus

  directus:
    container_name: directus
    image: directus/directus:latest
    ports:
      - 8055:8055
    volumes:
      # By default, uploads are stored in /directus/uploads
      # Always make sure your volumes matches the storage root when using
      # local driver
      - ./uploads:/directus/uploads
      # Make sure to also mount the volume when using SQLite
      # - ./database:/directus/database
      # If you want to load extensions from the host
      - ./extensions:/directus/extensions
    networks:
      - directus
    depends_on:
      - cache
      - database
    environment:
      KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
      SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'

      DB_CLIENT: 'mysql'
      DB_HOST: 'database'
      DB_PORT: '3066'
      DB_DATABASE: 'db_name'
      DB_USER: 'root'
      DB_PASSWORD: 'root_pw'

      CACHE_ENABLED: 'true'
      CACHE_STORE: 'redis'
      CACHE_REDIS: 'redis://cache:6379'

      ADMIN_EMAIL: '[email protected]'
      ADMIN_PASSWORD: 'd1r3ctu5'

      # Make sure to set this in production
      # (see https://docs.directus.io/self-hosted/config-options#general)
      # PUBLIC_URL: 'https://directus.example.com'

networks:
  directus:```
#

same problem

#

i could add restart: on-failure

turbid quiver
#

your db port in your directus config is wrong

#

and you'll have to add this command in under your db image:

image: mariadb
    command: --default-authentication-plugin=mysql_native_password
soft talon
#

thank you so much, after adding restart: on-failure it worked

mild dustBOT
#

✅ MariaDB and Directus issue in Docker: ECONNREFUSED

mild dustBOT
soft talon
#

sadly the issue reappeared, i had an copy & past error:

     - ./data:/var/lib/mysq```

after adding the missing l it stopped working, i'm confused af
soft talon
#
services:
  database:
    container_name: database
    image: mariadb:latest
    command: --default-authentication-plugin=mysql_native_password
    ports:
      - 3306:3306
    volumes:
      - database-data:/var/lib/mysql
    networks:
      - directus
    environment:
      MYSQL_ROOT_PASSWORD: "root_pw"
      MYSQL_DATABASE: "db_name"
      MYSQL_USER: "db_user"
      MYSQL_PASSWORD: "db_user_pw"

  cache:
    container_name: cache
    image: redis:6
    networks:
      - directus

  directus:
    container_name: directus
    image: directus/directus:latest
    ports:
      - 8055:8055
    volumes:
      # By default, uploads are stored in /directus/uploads
      # Always make sure your volumes matches the storage root when using
      # local driver
      - ./uploads:/directus/uploads
      # Make sure to also mount the volume when using SQLite
      # - ./database:/directus/database
      # If you want to load extensions from the host
      - ./extensions:/directus/extensions
    networks:
      - directus
    depends_on:
      - cache
      - database
    environment:
      KEY: "255d861b-5ea1-5996-9aa3-922530ec40b1"
      SECRET: "6116487b-cda1-52c2-b5b5-c8022c45e263"

      DB_CLIENT: "mysql"
      DB_HOST: "database"
      DB_PORT: "3306"
      DB_DATABASE: "db_name"
      DB_USER: "root"
      DB_PASSWORD: "root_pw"

      CACHE_ENABLED: "true"
      CACHE_STORE: "redis"
      CACHE_REDIS: "redis://cache:6379"

      ADMIN_EMAIL: "[email protected]"
      ADMIN_PASSWORD: "d1r3ctu5"

      PORT: 8055

      # Make sure to set this in production
      # (see https://docs.directus.io/self-hosted/config-options#general)
      # PUBLIC_URL: 'https://directus.example.com'

networks:
  directus:

volumes:
  database-data:```
#

this works, mariadb saves in databse-data

#

it's a bit annoying that the volume isn't in the file system of the host machine

turbid quiver
#

it should be

soft talon
#

the workarounds in this thread didn't work for me, but whatever