Trouble deploying server-side to Heroku
Closed this issue · 3 comments
API repo: https://github.com/jessamarie/recall-api
I've created an API to fetch data from. It's all working locally, but I am having trouble properly deploying it. Here are the steps I have taken:
- Created heroku app and a deploying branch.
- Created account on MLAB
- Set an env variable with the database URI like so:
MONGOLAB_URI="mongodb://<myactualuser>:<myactualpassword>@ds135624.mlab.com:35624/recall_prod"
- Updated production database to be equal to
process.env.MONGOLAB_URI
, as shown here: https://github.com/jessamarie/recall-api/blob/master/config/env/production.js - Deployed to heroku with:
git push heroku deploying:master
https://recall-app-api.herokuapp.com/api/topics should display an array of objects, but instead I get an error that says: "Application error. An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details."
Build log:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 6.x...
Downloading and installing node 6.11.3...
Detected package-lock.json: defaulting npm to version 5.x.x
Bootstrapping npm 5.x.x (replacing 3.10.10)...
npm 5.4.2 installed
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (package.json + package-lock)
up to date in 1.283s
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 17.6M
-----> Launching...
Released v4
https://recall-app-api.herokuapp.com/ deployed to Heroku
@jessamarie Have you run your seed file yet?
@AWhitleyGA When I do that I get this error in the terminal:
[jessa@Jessicas-MacBook-Pro recall-api]$ heroku run npm run seed
▸ heroku-cli: update available from 6.13.10 to 6.14.21-d83c94b
Running npm run seed on ⬢ recall-app-api... up, run.3062 (Free)
> recall-api@1.0.0 seed /app
> node config/db/seed.js
(node:18) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
(node:18) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
{ MongoError: failed to connect to server [undefined:27017] on first connect [MongoError: getaddrinfo ENOTFOUND undefined undefined:27017]
at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:336:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:280:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:187:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at connectErrorNT (net.js:1021:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'MongoError',
message: 'failed to connect to server [undefined:27017] on first connect [MongoError: getaddrinfo ENOTFOUND undefined undefined:27017]' }
@jessamarie What file is this require statement supposed to be pointing at?
https://github.com/jessamarie/recall-api/blob/master/config/db/connect.js#L4