Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to RDS MySQL from Heroku #384

Closed
matukosan opened this issue Apr 4, 2017 · 5 comments
Closed

Unable to connect to RDS MySQL from Heroku #384

matukosan opened this issue Apr 4, 2017 · 5 comments
Labels

Comments

@matukosan
Copy link

matukosan commented Apr 4, 2017

When using TypeORM in a Heroku app, I get this error message on server startup...guess I would need to use SSL to connect to RDS.

So my question is, how can I use SSL for a MySQL DB with TypeORM?

2017-04-04T22:12:11.992134+00:00 app[web.1]: { Error: getaddrinfo ENOTFOUND my-db.cevqsdxnwj1g.eu-central-1.rds.amazonaws.com my-db.cevqsdxnwj1g.eu-central-1.rds.amazonaws.com:3306 2017-04-04T22:12:11.992147+00:00 app[web.1]: at errnoException (dns.js:28:10) 2017-04-04T22:12:11.992149+00:00 app[web.1]: at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26) 2017-04-04T22:12:11.992150+00:00 app[web.1]: -------------------- 2017-04-04T22:12:11.992154+00:00 app[web.1]: at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:141:48) 2017-04-04T22:12:11.992155+00:00 app[web.1]: at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:52:41) 2017-04-04T22:12:11.992156+00:00 app[web.1]: at PoolConnection.connect (/app/node_modules/mysql/lib/Connection.js:130:18) 2017-04-04T22:12:11.992156+00:00 app[web.1]: at Pool.getConnection (/app/node_modules/mysql/lib/Pool.js:48:16) 2017-04-04T22:12:11.992157+00:00 app[web.1]: at /app/node_modules/typeorm/driver/mysql/MysqlDriver.js:249:28 2017-04-04T22:12:11.992159+00:00 app[web.1]: at MysqlDriver.retrieveDatabaseConnection (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:248:20) 2017-04-04T22:12:11.992160+00:00 app[web.1]: at MysqlDriver.<anonymous> (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:141:51) 2017-04-04T22:12:11.992160+00:00 app[web.1]: at step (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:32:23) 2017-04-04T22:12:11.992161+00:00 app[web.1]: at Object.next (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:13:53) 2017-04-04T22:12:11.992162+00:00 app[web.1]: at /app/node_modules/typeorm/driver/mysql/MysqlDriver.js:7:71 2017-04-04T22:12:11.992166+00:00 app[web.1]: at __awaiter (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:3:12) 2017-04-04T22:12:11.992167+00:00 app[web.1]: at MysqlDriver.createQueryRunner (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:134:16) 2017-04-04T22:12:11.992168+00:00 app[web.1]: at SchemaBuilder.<anonymous> (/app/node_modules/typeorm/schema-builder/SchemaBuilder.js:85:58) 2017-04-04T22:12:11.992168+00:00 app[web.1]: at step (/app/node_modules/typeorm/schema-builder/SchemaBuilder.js:32:23) 2017-04-04T22:12:11.992169+00:00 app[web.1]: at Object.next (/app/node_modules/typeorm/schema-builder/SchemaBuilder.js:13:53) 2017-04-04T22:12:11.992170+00:00 app[web.1]: at /app/node_modules/typeorm/schema-builder/SchemaBuilder.js:7:71 2017-04-04T22:12:11.992171+00:00 app[web.1]: code: 'ENOTFOUND', 2017-04-04T22:12:11.992172+00:00 app[web.1]: errno: 'ENOTFOUND', 2017-04-04T22:12:11.992172+00:00 app[web.1]: syscall: 'getaddrinfo', 2017-04-04T22:12:11.992173+00:00 app[web.1]: hostname: 'my-db.cevqsdxnwj1g.eu-central-1.rds.amazonaws.com', 2017-04-04T22:12:11.992174+00:00 app[web.1]: host: 'my-db.cevqsdxnwj1g.eu-central-1.rds.amazonaws.com', 2017-04-04T22:12:11.992175+00:00 app[web.1]: port: '3306', 2017-04-04T22:12:11.992176+00:00 app[web.1]: fatal: true }

@pleerock
Copy link
Member

pleerock commented Apr 5, 2017

yes, see #278 for details.

@pleerock
Copy link
Member

pleerock commented Apr 5, 2017

in your case its mysql, so you have to use mysql-specific options

@matukosan
Copy link
Author

matukosan commented Apr 5, 2017

@pleerock thanks for your response, still the same error :/
locally it's working fine though, maybe a heroku issue?

I'm using this options for createConnection now:
return createConnection({ driver: { type: "mysql", host: config.db.uri, port: config.db.port, username: config.db.user, password: config.db.password, database: config.db.name, extra: { ssl: 'Amazon RDS' } }, entities: [ UserDBModel, TodoDbModel ], autoSchemaSync: true, })

also tried "rejectUnauthorized: false" with the same result.

@pleerock
Copy link
Member

pleerock commented Apr 5, 2017

try to setup connection with mysql package. If you still have problems then its your environment issue.

@matukosan
Copy link
Author

alright, seems to be a problem with heroku and ssl certs, thanks anyways

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants