title: Docker MYSQL '[2002] Connection refused'
body: <p>I was trying out Docker for the first time. Got a LEMP stack up and running, but I can't connect to the MYSQL Database. Not on my Symfony application, not on PHPMyAdmin. The applications are returning the following error code:</p>
  
  <blockquote>
    <p>An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused</p>
  </blockquote>
  
  <p>This is my docker-compose.yml:</p>
  
  <pre><code>nginx:
      image: tutum/nginx
      ports:
          - "80:80"
      links:
          - phpfpm
      volumes:
          - ./nginx/default:/etc/nginx/sites-available/default
          - ./nginx/default:/etc/nginx/sites-enabled/default
  
          - ./logs/nginx-error.log:/var/log/nginx/error.log
          - ./logs/nginx-access.log:/var/log/nginx/access.log
  phpfpm:
      build: phpfpm/
      ports:
          - "9000:9000"
      volumes:
          - ./public:/usr/share/nginx/html
  mysql:
    image: mariadb
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: admin
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: always
    links:
      - mysql
    ports:
      - 8183:80
    environment:
      MYSQL_USERNAME: admin
      MYSQL_ROOT_PASSWORD: admin
      PMA_ARBITRARY: 1
  </code></pre>
  
  <p>Dockerfile PHPFPM:</p>
  
  <pre><code>    FROM php:fpm
  
  RUN docker-php-ext-enable opcache
  RUN apt-get update \
    &amp;&amp; apt-get install -y --no-install-recommends libpq-dev \
    &amp;&amp; docker-php-ext-install mysqli pdo_pgsql pdo_mysql
  </code></pre>
  
  <p>GitHub URL: <a href="https://github.com/MolengraafFrank/DockerSymfony" rel="noreferrer">https://github.com/MolengraafFrank/DockerSymfony</a></p>
  
  <p>Could someone help me out? Thank you for your time.</p>