title: Node app can't connect to database after setting up with nginx, phpmyadmin, and mysql on Ubuntu16
body: <p>I've successfully set up an node app with nginx reverse proxy, mysql and phpmyadmin. There's no problem access the database using phpmyadmin or access the website. </p>
  
  <p>The error message I get when try to login:</p>
  
  <pre><code>Error: connect ECONNREFUSED my-ip-address:3306
  </code></pre>
  
  <p>Is this an issue with mysql connection? I've already checked the code with mysql connection and can't figure out what's wrong.</p>
  
  <pre><code>  var connection = require("mysql").createPool({
      host: "my-ip-address",
      user: "root",
      password: "my-password",
      database: "database-name",
      dateStrings: true,
      charset: "utf8mb4"
    }); 
  </code></pre>
  
  <p>The /etc/nginx/sites-available/default file</p>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server;
  
      root /var/www/html;
  
      index index.php index.html index.htm index.nginx-debian.html;
      server_name "my ip address";
  
      location / {
          proxy_pass http://localhost:8010/;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
      }
  
      location /phpmyadmin {
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
  
        location ~ ^/phpmyadmin/(.+\.php)$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME 
          $document_root$fastcgi_script_name;
  
        }
  
      location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
          root /usr/share/;
        }
      }
  
  
      location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
      }
  
      location ~ /\.ht {
              deny all;
           }
  }
  </code></pre>