title: ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED ::1:3306
body: <p>I am running into an issue with connection with Sequelize v6.19.0, sqlite3 v5.0.6. I keep getting this error and not sure what to do next. I am using Node.js v18.x in react.js, deps: express, passport, session, and handlebars.</p>
  <p><strong>My config file looks like this:</strong></p>
  <pre><code>`const config = require('dotenv'); // this is important!
  module.exports = {
  &quot;development&quot;: {
      &quot;username&quot;: process.env.DB_USER,
      &quot;password&quot;: process.env.DB_PASS,
      &quot;database&quot;: &quot;f47qfgaxx78y6jn2&quot;,
      &quot;host&quot;: process.env.DB_HOST,
      &quot;dialect&quot;: &quot;mysql&quot;
  },
  &quot;test&quot;: {
      &quot;username&quot;: &quot;root&quot;,
      &quot;password&quot;: null,
      &quot;database&quot;: &quot;database_test&quot;,
      &quot;host&quot;: &quot;127.0.0.1&quot;,
      &quot;dialect&quot;: &quot;mysql&quot;
  },
  &quot;production&quot;: {
       &quot;use_env_variable&quot;: &quot;JAWSDB_URL&quot;,
        &quot;dialect&quot;: &quot;mysql&quot;
  },
  };`
  </code></pre>
  <pre><code>   **My index.js looks like this:**
  </code></pre>
  <pre><code> `   'use strict';
  
  const fs = require('fs');
  const path = require('path');
  const Sequelize = require('sequelize');
  const basename = path.basename(__filename);
  const env = process.env.NODE_ENV || 'development';
  const config = require(__dirname + '/../config/config.js')[env];
  const db = {};
  
  let sequelize;
  if (config.use_env_variable) {
    sequelize = new Sequelize(process.env[config.use_env_variable], config);
  } else {
    sequelize = new Sequelize(config.database, config.username, config.password, config);
  }
  
  fs
    .readdirSync(__dirname)
    .filter(file =&gt; {
      return (file.indexOf('.') !== 0) &amp;&amp; (file !== basename) &amp;&amp; (file.slice(-3) === '.js');
    })
    .forEach(file =&gt; {
      const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
      db[model.name] = model;
    });
  
  Object.keys(db).forEach(modelName =&gt; {
    if (db[modelName].associate) {
      db[modelName].associate(db);
    }
  });
  
  db.sequelize = sequelize;
  db.Sequelize = Sequelize;
  
  module.exports = db;`
  </code></pre>
  <pre><code>    -------------------------------------------------
  </code></pre>
  <p>The error references the connection manager in Node_modules/Sequelize/dialects/abstract/...at the async function...
  it looks like this:</p>
  <pre><code> `async _connect(config) {
      await this.sequelize.runHooks(&quot;beforeConnect&quot;, config);
      const connection = await this.dialect.connectionManager.connect(config);
      await this.sequelize.runHooks(&quot;afterConnect&quot;, connection, config);
      return connection;
    }`
  </code></pre>
  <pre><code>    -------------------------------------------------
  
      **My server.js looks like this:**
  </code></pre>
  <pre><code>`const app = express();
  app.use(express.urlencoded({ extended: true }));
  app.use(express.json());
  app.use(express.static(&quot;public&quot;));
  // We need to use sessions to keep track of our user's login status
  app.use(
    session({ secret: &quot;keyboard cat&quot;, resave: true, saveUninitialized: true })
  );
  app.use(passport.initialize());
  app.use(passport.session());
  
  // Set Handlebars as the default templating engine.
  app.engine(&quot;handlebars&quot;, exphbs({ defaultLayout: &quot;main&quot; }));
  app.set(&quot;view engine&quot;, &quot;handlebars&quot;);
  
  // Requiring our routes
  require(&quot;./routes/html-routes.js&quot;)(app);
  require(&quot;./routes/api-routes.js&quot;)(app);
  
  // Syncing our database and logging a message to the user upon success
  db.sequelize.sync({ force: false }).then(() =&gt; {
    app.listen(PORT, () =&gt; {
      console.log(
        &quot;==&gt;   Listening on port 3000. Visit http://localhost:3000/ in your browser.&quot;,
        PORT,
        PORT
      );
    });
  });`
  
  </code></pre>
  <p>What am I missing?</p>