I created a docker container with docker-compose in my VPS and I want to access it from my local computer but the connection will refuse. also, I allowed the 3306 port in the VPS.

my docker-compose.yml file:

version: "3"

    image: mariadb
    container_name: mariadb
    restart: 'always'
      - ./conf:/etc/mysql
      MYSQL_ROOT_PASSWORD: ${password}
      MYSQL_DATABASE: ${database}
      MYSQL_USER:  ${username}
      MYSQL_PASSWORD: ${password}
      - 3306:3306

how may I access the MariaDB server from my local computer?

1 Answer 1


Check netstat -tlpn on the VPS, can you see or something like that? If so, check the firewall. Both the firewall in the operating system and the firewall from the VPS provider (if there is any). As a last resort (and not a bad idea) - you can connect to your VPS via VPN - there are good openvpn tutorials on the internet. The reason why the VPN is a good idea - especially for a development server is that you may need to allow the user from everywhere (if you do not have a static IP address) and if you accidentally create some 'testuser' with 'testpassword' anybody from the internet will be able to connect to your db. So use good passwords, limit access to your public IP and use VPN if possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.