DEV Community

Discussion on: How to Dockerize a Node app and deploy to Heroku

Collapse
 
rodrigogalvez profile image
Rodrigo Gálvez

Good tutorial. I followed step by step. But I got an error when execute the last step: heroku open. :(

2020-10-30T17:33:26.078663+00:00 app[web.1]: /app/node_modules/mongodb-core/lib/topologies/server.js:431
2020-10-30T17:33:26.078664+00:00 app[web.1]: new MongoNetworkError(
2020-10-30T17:33:26.078665+00:00 app[web.1]: ^
2020-10-30T17:33:26.078665+00:00 app[web.1]:
2020-10-30T17:33:26.078666+00:00 app[web.1]: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
2020-10-30T17:33:26.078667+00:00 app[web.1]: at TCPConnectWrap.afterConnect as oncomplete {
2020-10-30T17:33:26.078667+00:00 app[web.1]: name: 'MongoNetworkError',
2020-10-30T17:33:26.078667+00:00 app[web.1]: errorLabels: [Array],
2020-10-30T17:33:26.078668+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-10-30T17:33:26.078668+00:00 app[web.1]: }]
2020-10-30T17:33:26.078670+00:00 app[web.1]: at Pool. (/app/node_modules/mongodb-core/lib/topologies/server.js:431:11)
2020-10-30T17:33:26.078670+00:00 app[web.1]: at Pool.emit (node:events:327:20)
2020-10-30T17:33:26.078670+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/pool.js:557:14
2020-10-30T17:33:26.078671+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/connect.js:39:11
2020-10-30T17:33:26.078671+00:00 app[web.1]: at callback (/app/node_modules/mongodb-core/lib/connection/connect.js:261:5)
2020-10-30T17:33:26.078672+00:00 app[web.1]: at Socket. (/app/node_modules/mongodb-core/lib/connection/connect.js:286:7)
2020-10-30T17:33:26.078672+00:00 app[web.1]: at Object.onceWrapper (node:events:434:26)
2020-10-30T17:33:26.078672+00:00 app[web.1]: at Socket.emit (node:events:327:20)
2020-10-30T17:33:26.078673+00:00 app[web.1]: at emitErrorNT (node:internal/streams/destroy:194:8)
2020-10-30T17:33:26.078673+00:00 app[web.1]: at emitErrorCloseNT (node:internal/streams/destroy:159:3)
2020-10-30T17:33:26.078673+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:80:21) {
2020-10-30T17:33:26.078674+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-10-30T17:33:26.078674+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-10-30T17:33:26.078674+00:00 app[web.1]: }

Collapse
 
pacheco profile image
Thiago Pacheco

Hello Rodrigo, I am so sorry for the delay, I think I missed your comment before.

Based on the logs you sent, it seems like you don't have the MONGODB_URI environment variable defined in your application, so the app is trying to connect to a database in localhost:27017 that does not exist.