В чем может быть ошибка подключения?
original: Error: getaddrinfo ENOTFOUND localhost;
index.js
require('dotenv').config({ path: __dirname + '/.env' });
const express = require('express');
const sequelize = require('./db');
const PORT = process.env.PORT || 5000; // Порт на котором приложение будет работать
// process.env обращение к файлу env
const app = express();
const start = async () => {
try {
await sequelize.authenticate();
await sequelize.sync();
console.log('123')
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
} catch (e) {
console.log(e)
}
}
start();
db.js
const { Sequelize } = require('sequelize');
module.exports = new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASSWORD,
{
dialect: 'postgres',
host: process.env.DB_HOST,
port: process.env.DB_PORT
}
)
.env
PORT = 7000;
DB_NAME = online_store;
DB_USER = postgres;
DB_PASSWORD = 123321;
DB_HOST = localhost;
DB_PORT = 5432;