Search code examples
node.jsherokusails.jsinternal-server-errorheroku-postgres

Internal Server Error on heroku sails deploy


I am trying to deploy my sails.js app to heroku. I have deployed it but whenever I open a page which requires data from DB it says Internal Server Error. I think it might be a problem with my DB connection. I have created a postgresql DB on heroku and have set the connections in connections.js. Connection.js code is

module.exports.connections = {
     'mysql-adapter': {
         module: 'sails-mysql',
         url: "postgres://username:[email protected]:5432/dcebipdspqn7rn",
         port: 5432,
         schema:true
     }
};

I have been searching on the net for 2 days and have tried many tweaks but none has worked for me. Kindly tell me how to solve this issue. Thanks in advance.

UPDATE:

I checked the logs and it says

←[33m2015-02-25T14:20:38.793179+00:00 app[web.1]:←[0m  Could not render view "displayroute/viewRoute".  Tried locating view file @ "/app/views/displayroute/view
Route". Layout configured as "layout", so tried using layout @ "/app/views/layout")

However, the view is rendered correctly on localhost.


Solution

  • Your connection definition looks completely wrong and schema key should be in the models config object (either in config/models.js or in the api/models/YourModelDefinition.js or on the sails.config.models object).

    I would reference the examples in connections.js found here https://github.com/balderdashy/sails-docs/blob/master/anatomy/myApp/config/connections.js.md

    Remember that if you are using postgres then you need to install the adapter

    npm install sails-postgresql