1

I'm unable to connect remotely from my local machine, everything worked well but suddenly it won't let me to the mysql database anymore. I tried every possible combinations, but none of them worked for me.

I have my PC and Laptop running Windows 10/11 with WSL2 (Ubuntu 22.04). I have a droplet (VPS) at Digitalocean running Ubuntu with Docker. There are 3 different docker containers spinning up (server, database and client). They can communicate with each other without any problem.

When I want to connect from my Laptop (Win 11 WSL2) to the docker "database" container running mysql, it won't work. Ports are open and exposed to the host.

It works only when I connect from my PC with Datagrip software, which was configured before it got messed up, but somehow it still works and allows me to connect to the database. It means it's configured correctly, but I'm unable to connect from other machine.

Is there anything I'm missing ?

Here is my docker-compose.yml:

version: '3.9'

services:
  api:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: api
    restart: on-failure
    env_file: .env
    environment:
      - DB_HOST=mysql
    volumes:
      - .:/app
    ports:
      - ${APP_PORT}:${APP_PORT}
      - ${WSS_PORT}:${WSS_PORT}
    depends_on:
      - mysql
    networks:
      - appnet
    cpus: 0.4
    mem_reservation: '512M'
    mem_limit: '1152M'

  mysql:
    image: mysql:8.0
    container_name: mysql
    command: mysqld --default-authentication-plugin=caching_sha2_password
    restart: always
    env_file: .env
    environment:
      - MYSQL_ROOT_HOST=%
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
      - MYSQL_DATABASE=${DB_NAME}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - mysql-data:/var/lib/mysql
    ports:
      - ${DB_PORT}:${DB_PORT}
    networks:
      - appnet
    cpus: 0.4
    mem_reservation: '256M'
    mem_limit: '512M'

networks:
  appnet:

volumes:
  mysql-data:
9
  • I’m voting to close this question because this is not even close to being a supportable configuration.
    – Greg Askew
    Commented Feb 23 at 11:14
  • @GregAskew Sir, please, can you explain me how should I rephrase my problem so It will be good for this community ? It's been voted to close on stackoverflow, they suggest it to post here, now here the same story. I believe there is someone who can give me some relevant solution or suggestion at least, so please correct me but dont vote for close as I provided a code sample Commented Feb 23 at 11:34
  • Community? I'm more concerned about the poor people that may inherit and have to support these deliberately poorly designed systems where the status report is "messed up but somehow still works"
    – Greg Askew
    Commented Feb 23 at 11:55
  • That's exactly what I'm coming with, a poorly designed system which is messed up, like you stated, that's why I seek for some help. I genuinely do not understand what's wrong when someone who asks for a help by providing his code to community to take a look and point into right direction. Firewall problem, network problem, OS related problem, server configuration done wrong, whatever it can be. Eye of the expert could probably instantly determine what's wrong and drop his suggestion Commented Feb 23 at 14:14
  • This setup is a shambles. Whoever did this does not like people. But it works when Jetbrains Datagrip is running so there is that.
    – Greg Askew
    Commented Feb 23 at 14:19

0

You must log in to answer this question.

Browse other questions tagged .