12

I run my server.js file and I have this error:

Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:4305
at Handshake._callback >   (c:\Users\alexa\WebstormProjects\ToDoSPA\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:76:20)
at Handshake.Sequence.end (c:\Users\alexa\WebstormProjects\ToDoSPA\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
at Protocol.handleNetworkError (c:\Users\alexa\WebstormProjects\ToDoSPA\node_modules\mysql\lib\protocol\Protocol.js:364:14)
at Connection._handleNetworkError (c:\Users\alexa\WebstormProjects\ToDoSPA\node_modules\mysql\lib\Connection.js:384:18)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1253:8)
at doNTCallback2 (node.js:452:9)
at process._tickCallback (node.js:366:17)

I don't understand why I'm getting the above mentioned error.

Alex
  • 8,461
  • 6
  • 37
  • 49
struggleale
  • 121
  • 1
  • 1
  • 5
  • 2
    The error seems pretty self-explanatory: your Node code cannot connect to port 4305 of localhost. – robertklep Dec 23 '15 at 12:03
  • 2
    Yes, I understood that, but I don't understand why, and what do I have to do in order to make things work..I am not running anything else on port 4305 – struggleale Dec 23 '15 at 13:29

4 Answers4

7

You didn't start your database or wrong database config check db config: var sequelize = new Sequelize(<your config>) or start Database

trquoccuong
  • 2,857
  • 2
  • 20
  • 26
5

Start your database server. It's coming because your database server is not running yet, that's why it refused the connection from app to database.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
4

On macOS, I had the same problem. The reason is Postgres service is not properly started. Make sure via running the command- brew services list Status of Postgres one will be yellow(not properly started) and others are green(means properly started)

The solution is for macOS(Run below 3 command one by one in your terminal),

rm -f /usr/local/var/postgres/postmaster.pid
brew services restart postgresql
brew services list

Now you can see hopefully the status of postgresql is green too. Now it will work.

Debotos Das
  • 519
  • 1
  • 6
  • 17
0

Check your DataBase connection, if you are using localhost, Don't forget to turn on the localhost connection. In my case, after open connection in Postgresql by typing

sudo service postgresql start

it works fine.