I am trying to deploy my Strapi app to Heroku with a mongoDB but receive this error every time I try to deploy.
debug ⛔️ Server wasn't able to start properly.
2020-06-11T10:38:53.257748+00:00 app[web.1]: [2020-06-11T10:38:53.257Z] error Error connecting to the Mongo database. Server selection timed out after 30000 ms
2020-06-11T10:38:53.268085+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-06-11T10:38:53.268583+00:00 app[web.1]: npm ERR! errno 1
2020-06-11T10:38:53.270443+00:00 app[web.1]: npm ERR! [email protected] start: `strapi start`
2020-06-11T10:38:53.270697+00:00 app[web.1]: npm ERR! Exit status 1
The app works locally and I have followed numerous tutorials (1, 2), including many versions of the offical Strapi documentation in order to get this working but they all result in this error. I have looked at similar Stack questions / Strapi github Issues to see if my issue can be solved by adapting their answers but nothing works.
I have ensured my heroku config
database_url and database_name matches my database_uri
string, and I created the strapi app with yarn create strapi-app backend
then selected mongo, making sure not to use --quickstart
.
My full strapi app, including database.js, server.js, *config/environments/production/database.json
can be viewed here https://github.com/KyleSFraser/Portfolio/tree/master/backend
I've been going in circles constantly rebuilding the backend using the docs or tutorials trying to deploy. I'd really appreciate any pointers to solve this recurring issue and successfully deploy my mongoDB using Heroku & Strapi.
EDIT Removing previous config vars now that it is working
DATABASE_
env vars in your Heroku app? - Maxim OrlovDATABASE_SSL=true
in Heroku to match"ssl": true
fromdatabase.json
. If that still doesn't work then I'm not really sure what the problem could be. Maybe someone else can spot something. - Maxim Orlov