1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

express mysql docker-compose Error: connect ECONNREFUSED

Last updated at Posted at 2020-06-27

:o: 解決策

const express = require('express')
const app = express()

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'mysql', // localhostは間違い, 0.0.0.0は間違い
  port     : 3306,
  user     : 'root',
  password : 'password',
  database : 'testdb'
});

対象

docker-composeでnodejs(express), mysqlを立ち上げて接続しようとしてエラーが出た人。

自分の場合、hostを修正した場合に成功しました。
user, password, databaseは各自確認してください。

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?