jmogera
jmogera

Reputation: 1759

Getting ETIMEDOUT error connecting to AWS MySQL DB from Heroku

So I have followed all the steps described here: https://devcenter.heroku.com/articles/amazon_rds

When I run the heroku config command, I get:

DATABASE_URL: mysql2://[username]:[password]@hostname...

So I have added the configuration along with certificate in the ./config folder

When I try to login, the connection times out and this is what is in the log:

2014-01-25T16:26:59.037529+00:00 app[web.1]: Express server listening on port 44600
2014-01-25T16:29:18.687464+00:00 heroku[api]: Add DATABASE_URL config by [email protected]
2014-01-25T16:29:18.735263+00:00 heroku[api]: Release v11 created by [email protected]
2014-01-25T16:29:18.882191+00:00 heroku[web.1]: State changed from up to starting
2014-01-25T16:29:21.439095+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-01-25T16:29:22.778653+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2014-01-25T16:29:22.935805+00:00 app[web.1]: connect.multipart() will be removed in connect 3.0
2014-01-25T16:29:22.936445+00:00 app[web.1]: visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
2014-01-25T16:29:22.936779+00:00 app[web.1]: connect.limit() will be removed in connect 3.0
2014-01-25T16:29:23.064077+00:00 app[web.1]: Express server listening on port 23430
2014-01-25T16:29:24.833326+00:00 heroku[web.1]: Process exited with status 143
2014-01-25T16:29:23.396737+00:00 heroku[web.1]: State changed from starting to up
2014-01-25T16:30:14.740476+00:00 app[web.1]: [90mPOST /login [32m200 [90m29992ms[0m
2014-01-25T16:30:14.736443+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path=/login host=www.novalist.co request_id=8ddc9973-03e4-4019-b47f-5da2efd84099 fwd="100.2.120.12" dyno=web.1 connect=3ms service=30001ms status=503 bytes=0
2014-01-25T16:30:59.002003+00:00 app[web.1]: [90mGET /login [32m200 [90m1016ms - 687b[0m
2014-01-25T16:30:59.007349+00:00 heroku[router]: at=info method=GET path=/login host=www.novalist.co request_id=bd43af72-53c6-4507-8e2c-ad3e318e36f4 fwd="100.2.120.12" dyno=web.1 connect=2ms service=1028ms status=200 bytes=687
2014-01-25T16:30:59.445343+00:00 app[web.1]: [90mGET /stylesheets/index-foundation.css [36m304 [90m9ms[0m
2014-01-25T16:30:59.457731+00:00 app[web.1]: [90mGET /stylesheets/style.css [32m200 [90m244ms - 1.07kb[0m
2014-01-25T16:30:59.466690+00:00 heroku[router]: at=info method=GET path=/stylesheets/style.css host=www.novalist.co request_id=c21b445c-941d-4cbb-ab68-a71fab00e24c fwd="100.2.120.12" dyno=web.1 connect=2ms service=254ms status=200 bytes=1098
2014-01-25T16:31:35.144892+00:00 app[web.1]: [90mPOST /login [32m200 [90m29998ms[0m
2014-01-25T16:31:52.078494+00:00 app[web.1]:     at errnoException (net.js:901:11)
2014-01-25T16:31:52.078494+00:00 app[web.1]:     at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:110:26)
2014-01-25T16:31:52.078494+00:00 app[web.1]:     at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:42:41)
2014-01-25T16:31:52.078494+00:00 app[web.1]:     at Connection.connect (/app/node_modules/mysql/lib/Connection.js:81:18)
2014-01-25T16:31:52.078494+00:00 app[web.1]:     at Strategy.authenticate (/app/node_modules/passport-local/lib/passport-local/strategy.js:89:10)
2014-01-25T16:31:52.078494+00:00 app[web.1]: 
2014-01-25T16:31:52.078720+00:00 app[web.1]:     at pass (/app/node_modules/express/lib/router/index.js:145:5)
2014-01-25T16:31:52.078494+00:00 app[web.1]:     at Strategy.module.exports [as _verify] (/app/auth.js:16:14)
2014-01-25T16:31:52.078494+00:00 app[web.1]: Error: connect ETIMEDOUT
2014-01-25T16:31:52.078720+00:00 app[web.1]:     at Passport.authenticate (/app/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
2014-01-25T16:31:52.078494+00:00 app[web.1]:     --------------------
2014-01-25T16:31:52.078494+00:00 app[web.1]:     at Object.afterConnect [as oncomplete] (net.js:892:19)
2014-01-25T16:31:52.078720+00:00 app[web.1]:     at callbacks (/app/node_modules/express/lib/router/index.js:164:37)
2014-01-25T16:31:52.078720+00:00 app[web.1]:     at param (/app/node_modules/express/lib/router/index.js:138:11)
2014-01-25T16:31:52.078720+00:00 app[web.1]:     at attempt (/app/node_modules/passport/lib/passport/middleware/authenticate.js:243:16)
2014-01-25T16:31:53.691098+00:00 heroku[web.1]: Process exited with status 8
2014-01-25T16:31:53.707160+00:00 heroku[web.1]: State changed from up to crashed

Upvotes: 1

Views: 3482

Answers (1)

Andrey Sidorov
Andrey Sidorov

Reputation: 25456

Your rds port / host is not accessible from heroku. Change database security group and allow heroku ip to connect tcp/3306

Also note that node-mysql does not yet support ssl connections. If you need to connect to rds securely you may want to use node-mysql2 or node-mariasql

Upvotes: 4

Related Questions