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
Sails reverts to development connection when on heroku #2480
Comments
Yes, I am also experiencing exactly the same problems. I tried commented out the config/env/development.js Apart from that, this Problem doesn't exist, if I set the development.js to connect other DB than Mongo connection. |
I had the same problem. Worked around it by setting: config/env/development.js: connections: {
localMongo: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017,
...
}
},
models: {
connection: 'localMongo'
} config/env/production.js connections: {
productionMongo: {
adapter: 'sails-mongo',
host: 'remotehost1',
port: 27017,
...
}
},
models: {
connection: 'productionMongo'
} |
Same issue in here but probably it can be easily fixed in the future! |
Same issue. I used @leobudima solution. |
Same issue here and it only exists on Heroku, if I start my app locally with a NODE_ENV=production vs. NODE_ENV=development everything works fine... the NODE_ENV i set in my ProcFile and also via heroku tool belt no luck. I want to do the "right" thing and use connections.js but I think I am going to have to do what @leobudima has done. |
For what it's worth, I didn't encounter this issue until I upgraded my dyno to the cedar-14 stack. My project had until now been running on cedar (which is deprecated) using Sails v10.5, but immediately upon upgrading I experienced the same issue with my development connection being used rather than production. The solution provided by @leobudima served as a good temporary fix. |
I'm having the same issue but none of the suggestion above seem to work, so don't know what I'm missing. |
Im having the same issue, setting environment variables doesnt seem to do anything. I also tried the solution @leobudima mentioned and thats not working. Still looks to localhost for me no matter what. |
I've confirmed that no matter what, it always defaults to whatever connection you have in /config/env/development. |
I finally found the solution, in the package json from the sails app you have to change the start script.
and add the NODE_ENV variable to heroku.
|
Both @leobudima and @agustin3a solutions did not work for me. What causes the default to local? Apparently having multiple connections with the same adapter can cause the problem: http://stackoverflow.com/questions/22775028/sails-fails-to-load-when-using-remote-mongo-db |
I was seeing this issue - and removing other 'sails-mongo' configurations from config/connections.js seemed to fix it for me. There are other SO posts that contend one could put those directly in the config/env/* files as a potential fix as well. I assume in those fixes one would also remove any reference to the adapter in use from config/connections.js. |
Thanks for posting, @gkaimakas. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
I'm having the exact same problem on Bluemix |
|
I am using sails 0.12.10, and sails-mongo 0.12.5, I still can not connect to remote mongo db. And I also tried all possible solutions suggested by people. |
I had the same problem, so combined the @leobudima and @agustin3a solutions and works fine for me. |
I have been trying to deploy my sails app on heroku using mongolab as my mongodb.
I have used the following connections, one for development and one for production:
I have also set my local.js file to use development environment and out that file on gitignore.
Finally on my development.js I do the following
on my production.js
and on my package.json I changed the start script to node app.js --prod. When running locally everything works as expected, even when I run npm start, but when I deploy on heroku and look at the logs I see that it tries to connect to the localhost mongodb.
Is it a bug or am I doing something wrong?
The text was updated successfully, but these errors were encountered: