Password authentication failing for ghost blog on heroku server - node.js

I'm trying to setup Ghost(node.js blogging app) to run on a heroku server. I've followed this tutorial here but I'm getting an Application error when I load the app URL. Looking at the logs, I'm getting the following stack trace:
2016-12-16T10:00:08.185701+00:00 heroku[web.1]: Starting process with command `NODE_ENV=production node index.js`
2016-12-16T10:00:11.989635+00:00 app[web.1]:
2016-12-16T10:00:11.989655+00:00 app[web.1]: ERROR: password authentication failed for user "xxxxxxxxxxxxxx"
2016-12-16T10:00:11.989656+00:00 app[web.1]: error: password authentication failed for user "xxxxxxxxxxxxxx"
2016-12-16T10:00:11.989656+00:00 app[web.1]:
2016-12-16T10:00:11.989658+00:00 app[web.1]: at Connection.parseMessage (/app/node_modules/pg/lib/connection.js:361:17)
2016-12-16T10:00:11.989657+00:00 app[web.1]: at Connection.parseE (/app/node_modules/pg/lib/connection.js:534:11)
2016-12-16T10:00:11.989659+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/pg/lib/connection.js:105:22)
2016-12-16T10:00:11.989660+00:00 app[web.1]: at emitOne (events.js:96:13)
2016-12-16T10:00:11.989661+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:176:18)
2016-12-16T10:00:11.989662+00:00 app[web.1]: at TLSSocket.Readable.push (_stream_readable.js:134:10)
2016-12-16T10:00:11.989660+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2016-12-16T10:00:11.989663+00:00 app[web.1]: at TLSWrap.onread (net.js:548:20)
2016-12-16T10:00:11.989664+00:00 app[web.1]:
2016-12-16T10:00:12.059675+00:00 heroku[web.1]: Process exited with status 0
2016-12-16T10:00:12.098899+00:00 heroku[web.1]: State changed from starting to crashed
2016-12-16T10:00:11.574238+00:00 app[web.1]: WARNING: Ghost is attempting to use a direct method to send email.
2016-12-16T10:00:11.574254+00:00 app[web.1]: It is recommended that you explicitly configure an email service.
2016-12-16T10:00:11.575112+00:00 app[web.1]: Help and documentation can be found at http://support.ghost.org/mail.
2016-12-16T10:00:11.575114+00:00 app[web.1]:
2016-12-16T12:20:59.497399+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ai-blog.herokuapp.com request_id=a725a350-ade1-4f00-9b8a-125fac34eb23 fwd="82.46.0.56" dyno= connect= service= status=503 bytes=
2016-12-16T12:21:01.504908+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ai-blog.herokuapp.com request_id=cc0c4f9b-f3af-4867-942f-0c7f295f9b90 fwd="82.46.0.56" dyno= connect= service= status=503 bytes=
2016-12-16T12:21:03.381794+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ai-blog.herokuapp.com request_id=ee190254-0159-4ba0-aa74-6e58f661c966 fwd="82.46.0.56" dyno= connect= service= status=503 bytes=
It seems that the important part of the error here is that the password is failing: But I've double and tripled check the all of the heroku varibles are set correctly, i.e. no typos, no extra spaces added at the start end of the string.
Additionally, the app runs fine locally.
The issue seems relatively common, but I've tried most of the solutions from other posts and nothing seems to be resolving the issue.
Solutions that I've tried:
Checked all varibles for typos
Checked the correct database is promoted
Manually adding the user credendials to the remote database(For some reason I can still access the remote database through the command line)
Ran the following command heroku config:set PGSSLMODE=require
ensured that I'm using https in the url when connecting to the site through a browser
I've added the following to the db params in the production environment of my config.js ssl: true
I've also checked that I'm in production environment
Sugguestions that I haven't tried:
Someone suggested that node needs to be updated. But I can't see any way of updating whatever version of node it is that heroku uses.
Somone suggested that postgres needs to be updated. But I can't see any way of updating that on heroku servers either. However, I did update the version number in the package.json file from 4.1.1 to 4.5.5 and moved it from optionalDependencies to dependencies.
editing the pg_hba.conf - again, I imagine this file exists on heroku servers and I can't access it
Anyone got any ideas?

I encounter the same problem while trying to upgrade to Ghost version 0.11.3 and deploying to Heroku.
I was able to solve the problem by upgrading the PostgreSQL npm package.
In package.json:
{
"dependencies": {
"pg": "^4.5.5",
},
"optionalDependencies": {
"pg": "^4.5.5"
}
}
And you will also need to modify the npm-shrinkwrap.json file:
{
"dependencies": {
"pg": {
"version": "^4.5.5",
"from": "pg#4.5.5",
"resolved": "https://registry.npmjs.org/pg/-/pg-4.5.5.tgz",
"dependencies": {...}
}
}
}
After that, check that the PG npm package version was updated correctly by taking a look at Heroku's deploy log. It should say something like:
remote: -----> Build succeeded!
remote: ├── ...
remote: ├── pg#4.5.5
remote: ├── ...

Related

How to fix not found error with heroku deployment / no such file or directory

First, sorry for my poor English.
The problem is this.
Whenever I try to open heroku I get this screen:
Not Found
Whenever I try to heroku logs I get this screen:
2022-05-20T09:26:03.000000+00:00 app[api]: Build succeeded
...
2022-05-20T09:26:08.430002+00:00 app[web.1]: MongoDB database connection established successfully
...
2022-05-20T09:32:21.525922+00:00 heroku[router]: at=info method=GET path="/" host=protected-wildwood-11173.herokuapp.com request_id=f33e9e00-7573-4fa5-9ebf-7e9c54d04532 fwd="121.134.103.64" dyno=web.1 connect=0ms service=2ms status=404 bytes=412 protocol=https
2022-05-20T09:32:21.526199+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
And this is my codes
package.json
folder path
server.js
In my expectation
Heroku cannot cognize 'build'
wrong path ( server.js - deployment )
I haven't been able to do it for 7 days.
Please help me
crycrycry...

Heroku application stopped serving db2 connection

I have my app hosted on heroku for nearly 1 year, and in the past 24 hours, it stopped working. I get this in my logs:
2021-11-08T18:15:06.475815+00:00 app[web.1]: [Error: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "". Communication function detecting the error: "selectForConnectTimeout". Protocol specific error code(s): "115", "*", "*". SQLSTATE=08001
2021-11-08T18:15:06.475827+00:00 app[web.1]: ] {
2021-11-08T18:15:06.475828+00:00 app[web.1]: error: '[node-ibm_db] SQL_ERROR',
2021-11-08T18:15:06.475829+00:00 app[web.1]: sqlcode: -30081,
2021-11-08T18:15:06.475829+00:00 app[web.1]: state: '08001'
2021-11-08T18:15:06.475830+00:00 app[web.1]: }
2021-11-08T18:15:33.386490+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/login" host=www.mysite.ca request_id=3d627300-28d2-48af-a86e-60bdb950298a fwd="99.249.30.56" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
It seems to not like whatever is going on with db2. I can access my database no problem through my local machine, and see everything with in my db tables. I also have this directly from my heroku dashboard.
i am not able to figure out what the issue is. does anyone have any ideas?
Thanks to everyone for their answers. I did some more digging around, and turns out what solved it was reinstalling the db2 driver locally, and pushing it to heroku. Something must have changed that required an update to the db2 driver to connect with the heroku sevrer.

Host Provider Heroku doesn't seem to pick up concurrently command in "npm run start"

Stack Overflow Question
Host Provider Heroku doesn't seem to pick up concurrently command in "npm run start". I can get this start command to work with "heroku local web" but get the below log errors when running the same thing on heroku host.
I noticed that for some other node full stack projects, the backend is setup to run on startup. In these cases there is routing setup in express so that the request either routes to a backend route or is passed off to a static front endpape. My issues is that I don't have express to support this. I'm just running json-server on the backend (or trying) and my vue.js content on the front.
Is there a work around to get Heroku configured to start both the a front and backend server?
I can run the "npm run start" locally but not on Heroku:
It seems like Heroku (at least by default) is configured to start a node app by running "npm run start". As a result, I have the following entry in my package.json:
package.json
"start": "concurrently \"export NODE_ENV=production\" \"json-server --watch db.json\" \"vue-cli-service serve --mode production\""
Heroku Logs:
2021-10-17T18:30:52.000000+00:00 app[api]: Build succeeded
2021-10-17T18:30:54.001782+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-17T18:30:55.002829+00:00 app[web.1]:
2021-10-17T18:30:55.002845+00:00 app[web.1]: > my-vue-app#0.1.0 start /app
2021-10-17T18:30:55.002845+00:00 app[web.1]: > concurrently "export NODE_ENV=production" "json-server --watch db.json" "vue-cli-service serve --mode production"
2021-10-17T18:30:55.002846+00:00 app[web.1]:
2021-10-17T18:30:55.226381+00:00 app[web.1]: [1] /bin/sh: 1: json-server: not found
2021-10-17T18:30:55.227075+00:00 app[web.1]: [2] /bin/sh: 1: vue-cli-service: not found
2021-10-17T18:30:55.228104+00:00 app[web.1]: [2] vue-cli-service serve --mode production exited with code 1272021-10-17T18:30:55.228540+00:00 app[web.1]: [1] json-server --watch db.json exited with code 127
2021-10-17T18:30:55.228781+00:00 app[web.1]: [0] export NODE_ENV=production exited with code 0
2021-10-17T18:30:55.238234+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-17T18:30:55.238413+00:00 app[web.1]: npm ERR! errno 1
2021-10-17T18:30:55.242355+00:00 app[web.1]: npm ERR! my-vue-app#0.1.0 start: `concurrently "export NODE_ENV=production" "json-server --watch db.json" "vue-cli-service serve --mode production"`
2021-10-17T18:30:55.242419+00:00 app[web.1]: npm ERR! Exit status 1
2021-10-17T18:30:55.242477+00:00 app[web.1]: npm ERR!
2021-10-17T18:30:55.242529+00:00 app[web.1]: npm ERR! Failed at the my-vue-app#0.1.0 start script.
2021-10-17T18:30:55.242567+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-17T18:30:55.248113+00:00 app[web.1]:
2021-10-17T18:30:55.248206+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-17T18:30:55.248255+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-10-17T18_30_55_242Z-debug.log
2021-10-17T18:30:55.386385+00:00 heroku[web.1]: Process exited with status 1
2021-10-17T18:30:55.642820+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-17T18:30:59.838564+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myvueapp1.herokuapp.com request_id=eaa81f4f-8d66-4dcc-92e6-5ac730cf9c9c fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:31:00.272840+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myvueapp1.herokuapp.com request_id=a3108da6-5ba3-48cf-8bc4-4b5784a6d171 fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:32:51.000000+00:00 app[api]: Build started by user mark.johnson.
2021-10-17T18:33:54.181436+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myvueapp1.herokuapp.com request_id=91cd8f28-f155-4b58-b4ac-bb1539e06413 fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:33:54.362762+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myvueapp1.herokuapp.com request_id=8103d63b-9a7d-46f9-b2c1-5d662e77b539 fwd="73.181.221.158" dyno= connect= service= status=503 bytes= protocol=https
2021-10-17T18:34:35.091986+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-17T18:34:34.685663+00:00 app[api]: Deploy 6abb4c8b by user mark.johnson.
2021-10-17T18:34:34.685663+00:00 app[api]: Release v4 created by user mark.johnson.
2021-10-17T18:34:38.788809+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-17T18:34:41.024848+00:00 app[web.1]:
2021-10-17T18:34:41.024866+00:00 app[web.1]: > my-vue-app#0.1.0 start /app
2021-10-17T18:34:41.024866+00:00 app[web.1]: > concurrently "export NODE_ENV=production" "json-server --watch db.json" "vue-cli-service serve --mode production"
2021-10-17T18:34:41.024867+00:00 app[web.1]:
2021-10-17T18:34:41.548998+00:00 app[web.1]: [1] Done
2021-10-17T18:34:41.555274+00:00 app[web.1]: [1]
2021-10-17T18:34:41.555534+00:00 app[web.1]: [1] Resources
2021-10-17T18:34:41.555535+00:00 app[web.1]: [1] http://localhost:3000/table1
2021-10-17T18:34:41.555535+00:00 app[web.1]: [1] http://localhost:3000/table2
2021-10-17T18:34:41.555535+00:00 app[web.1]: [1]
2021-10-17T18:34:41.555536+00:00 app[web.1]: [1] Home
2021-10-17T18:34:41.555536+00:00 app[web.1]: [1] http://localhost:3000
2021-10-17T18:34:41.555536+00:00 app[web.1]: [1]
2021-10-17T18:34:41.555781+00:00 app[web.1]: [1] Type s + enter at any time to create a snapshot of the database
As I said here and here, the common approach in an enterprise architecture is to have one app by repository and server.
Imagine that your microservice (json) process needs to have more ram because handle heavy operations and since your web is an spa, does not need anything because it is just static files after npm run build. In this case, depending of the infrastructure, you could scale vertically/horizontally every artifact (api and web) easily. If you have several process in the same server, you would be backing up a little to the monolithic architecture. This is just one of the several advantages like:
https://michaelwashburnjr.com/blog/4-reasons-web-app-separated-frontend-backend
https://softwareengineering.stackexchange.com/a/299550/204271
Api and Web
In heroku and any platform, applications has its own port. Also you will have noticed that in your developer laptop:
vue app runs at : http://localhost:8080
api mock at http://localhost:3000/posts/1
As you can see , you have two apps here, each one with its own port. In the future, each one will have its own domain : acme.com and acme-api.com
Just for test
The usage of json-server to publish a single file (db.json) as a microservice or rest api is just for testing or poc purposes. It would be crazy to use concurrently in a real application for real users.
I used this on early development stage, when the api/microservice does not exist yet.
When api is ready to use and has its own http domain (http://acme-api.com) served on its own server, I set this new url on my web.
Two apps (api + web)
If you don't want to complicate and be prepared for a real enterprise deployment, you should create two different app on your heroku account
acme-web with your vue code. This usually needs to have the npm run dev, npm run build and npm run start. Your start script should be something like this: "start": "vue-cli-service serve --mode production"
acme-api with your real api/microservice source code(database connection and other features). Also in early stage (api does not exist yet) you could put here your db.json and you start script should look like this: "start": "json-server --watch db.json"
One app
Anyway, if you want or need to have all (web+api) in one server or container, you should use another provider like aws, gcp, azure, etc. On that provider your concurrently command will work.
On heroku, you can't run two diferent web process on the same dyno.
Workaround
As some framework does like MEAN, MERN & MEVN and other modern monolithics, you could use an express server to serve your api and your web.
This app should look like this:
var express = require('express');
var jsonServer = require('json-server');
var app = express();
//publish the static result of npm run build (vue)
//https://github.com/jrichardsz/nodejs-express-snippets/tree/master/simple-static-server
app.use('/',
express.static(path.join(__dirname, "site" || proces.env.SITE_FOLDER)),
);
//run json-server programmatically here
//https://github.com/typicode/json-server/issues/253#issuecomment-205509836
app.use('/api', jsonServer.router('db.json'));
app.listen(3000);
Variables by environment
If you opt for and advanced distributed architecturem and yo have at least two environments: testing and production and you don't want to change the variables from time to time when you switch your application from your laptop to next environments dev > testing > production you will need to properly handle your environment variables using the heroku manager.

How do I run this node express app on Heroku?

I already have one app running on Heroku just fine which I created a few weeks ago for the first time.
Here is the git repo for the functioning app - https://github.com/Sean-99-04/basic
However when I try to run my newest app, it does not work. It builds fine, but gives an application error when ran.
Here is the git repo for that - https://github.com/Sean-99-04/History-Blog
Also I am runnnig this through GitHub, not through Heroku CLI.
I have been searching online for the last 3 hours for answers and here are some things mentioned which I made sure to unclude:
Procfile with code "web:node ./server.js"
package.json with code "script": {"start": "node server.js"}
In server.js I have process.env.PORT and all other necessary process.env's
I greatly appreciate any help and thank you in advance.
This is the error in logs:
2021-01-11T16:50:16.910561+00:00 app[web.1]: npm ERR! Failed at the history-blog#1.0.0 start script.
2021-01-11T16:50:16.910689+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-01-11T16:50:16.915638+00:00 app[web.1]:
2021-01-11T16:50:16.915831+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-11T16:50:16.915958+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-11T16_50_16_911Z-debug.log
2021-01-11T16:50:16.988688+00:00 heroku[web.1]: Process exited with status 1
2021-01-11T16:50:17.025320+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-11T16:50:17.966848+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=history-blog.herokuapp.com request_id=f274158b-5399-49ab-97d9-5a83bb387a13 fwd="95.147.237.100" dyno= connect= service= status=503 bytes= protocol=https
As mentioned in the comments, the failure was caused by trying to loading dotenv. The reason that happened despite Heroku's default NODE_ENV being production is that you're assigning in the check, which returns the string development, which is truthy — so it gets loaded.
What you have: if ((process.env.NODE_ENV = "development")) {
What you want: if (process.env.NODE_ENV === "development") {

MongoDB not connecting to Heroku? Application Error

I tested it out using npm modules: "node-dev" on the backend.js and "serve" on the root directory of the folder.
I have these 2 guides that tried to help me:
http://www.tilcode.com/deploying-a-mean-stack-app-to-heroku/
and another one from scotch.io "Use MongoDB with a Node.js Application on Heroku"
What I didn't do from the articles that shouldn't matter: in tilcode, it said use to github to generate an SSH key...instead I made one using my mac and a terminal command using some guide.
To summarize my steps:
Login to heroku, create the app
use git commands to add, commit all the files in my github into heroku and pushed them into heroku
I even put the mlab addon and filled out the URI.
It deployed "successfully" but when visiting the app, it says "application failed"
My suspicions:
I do have another working app that uses postgreSQL...but I put it on 'maintenance mode' since my free account only allows for one active dynamo.
Instead of uploading all my node modules, I learned I could have heroku install it like this:
heroku config:set NPM_CONFIG_PRODUCTION=false
I think it may be how I referenced the backend from my frontend javascript.
// var API = 'http://localhost:5000';
var API = 'http://limitless-falls-21423.herokuapp.com';
var app = angular.module('HAL-app', ['ngRoute', 'ngCookies']);
// Some other stuff that came from sandbox app.js
app.directive('whenScrolled', function() {
return function(scope, elm, attr) {
var raw = elm[0];
elm.bind('scroll', function() {
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
scope.$apply(attr.whenScrolled);
}
});
};
});
Lastly, when I ran heroku logs --tail I got these messages:
2016-09-05T01:35:27.417956+00:00 app[web.1]: npm ERR! Linux 3.13.0-93-generic
2016-09-05T01:35:27.418339+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-09-05T01:35:27.418593+00:00 app[web.1]: npm ERR! node v5.11.1
2016-09-05T01:35:27.418931+00:00 app[web.1]: npm ERR! npm v3.8.6
2016-09-05T01:35:27.419219+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-09-05T01:35:27.419386+00:00 app[web.1]: npm ERR! hallocam#1.0.0 start:
node backend.js
2016-09-05T01:35:37.178679+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=limitless-falls-21423.herokuapp.com request_id=4bc9639f-3f64-4c0b-9b0d-d99b967f1b36 fwd="73.54.129.252" dyno= connect= service= status=503 bytes=
******EDIT after Yashua's comment**
I now get a "cannot get" message when visiting the app. Was kinda hesitant about limiting my heroku variables to just the:
NODE_ENV=production
But I guess it makes since since if I keep my mongodb (mongo labs) credentials uploaded and hidden using .gitignore.
Anyway, I'm still thinking it's not "getting" my routes which I have setup my angularjs file like this:
// var API = 'http://localhost:5000'; ##this is the old way to connect my front end factory routes to the backend hosted on 5000
I have it like this right now
var API = 'http://obscure-brook-35938.herokuapp.com/';
I think it may have to look like this:
var API = process.env.PORT
The purpose of the API is to be used for my angular factories like this:
app.factory('backEnd', function($http) {
return {
getSignUp: function(data) {
return $http({
method: 'POST',
url: API + '/signup',
data: data
});
},
getLogin: function(data) {
return $http({
method: 'POST',
url: API + '/login',
data: data
});
},
New Heroku logs --tail
2016-09-05T15:42:52.796464+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brook-35938.herokuapp.com request_id=41fa32e2-42cc-426d-a0d0-ef6755329497 fwd="73.54.129.252" dyno=web.1 connect=1ms service=18ms status=404 bytes=243
2016-09-05T15:42:53.893156+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brook-35938.herokuapp.com request_id=dec235fd-6d54-42e6-b0cc-2f83920d500d fwd="73.54.129.252" dyno=web.1 connect=1ms service=8ms status=404 bytes=243
2016-09-05T15:42:54.602312+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brook-35938.herokuapp.com request_id=8ceb054b-78e9-49b8-bdee-286ca6efcb0d fwd="73.54.129.252" dyno=web.1 connect=1ms service=3ms status=404 bytes=243
Hard to tell offhand but here are some pointers:
I looked at your repo and your package.json is invalid in 2 places. Use a JSON validator.
Secondly your frontend app will not be an issue. You should be able to go to the server URL directly and not have it crashed.
Change your database password if you haven't already. I see that you deleted your mongo_creds.json file but the history is available on GitHub.
The only vars you should need on Heroku is NODE_CONFIG set to production.
I'm closing this thread because it's getting pretty lengthy and a separate problem has arose. As #yashua said, the best way to solve this mongodb/heroku problems is to take it one step at a time. Some tools I've learned from this experience:
If using NPMs to test, that's great as it builds confidence. But to truly test heroku, use its 'heroku local' or 'heroku local web' to test it out locally first (serve it up), then it'll help narrow down further issues when deploying/'git push heroku master'
Build a solid understanding of how .env files work (really, they're
just configuration files to store credential information). I've been
using .json files to store mine, then use .gitignore to stop them
from appearing publicly. Heroku has its own secret keepers in the
form of Procfile and .env
I'm up to a point now where I consolidated my backend/frontend into one root directory. But my frontend and backend use 2 different ports to work when it should only use one. Not sure the best way to approach that since when I do [supposedly] feed them all the same port as 'process.env.MONGOLAB_URI' I get an error that hints that I have it wrong.
2016-09-05T23:36:51.802697+00:00 app[web.1]: /app/node_modules/mongodb/lib/server.js:261
2016-09-05T23:36:51.802698+00:00 app[web.1]: process.nextTick(function() { throw err; })
2016-09-05T23:36:51.802698+00:00 app[web.1]: ^
2016-09-05T23:36:51.803862+00:00 app[web.1]: MongoError: failed to connect to server [#:27017] on first connect
2016-09-05T23:36:51.803864+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:313:35)
2016-09-05T23:36:51.803864+00:00 app[web.1]: at emitOne (events.js:96:13)
2016-09-05T23:36:51.803865+00:00 app[web.1]: at Pool.emit (events.js:188:7)
2016-09-05T23:36:51.803865+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:260:12)
2016-09-05T23:36:51.803866+00:00 app[web.1]: at Connection.g (events.js:286:16)
2016-09-05T23:36:51.803867+00:00 app[web.1]: at emitTwo (events.js:106:13)
2016-09-05T23:36:51.803867+00:00 app[web.1]: at Connection.emit (events.js:191:7)
2016-09-05T23:36:51.803868+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:162:49)
2016-09-05T23:36:51.803868+00:00 app[web.1]: at Socket.g (events.js:286:16)
2016-09-05T23:36:51.803869+00:00 app[web.1]: at emitOne (events.js:96:13)
2016-09-05T23:36:51.803870+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2016-09-05T23:36:51.803870+00:00 app[web.1]: at connectErrorNT (net.js:1016:8)
2016-09-05T23:36:51.803871+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:74:11)
2016-09-05T23:36:51.803871+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:98:9)
2016-09-05T23:36:51.881752+00:00 heroku[web.1]: State changed from starting to crashed
2016-09-05T23:36:51.867426+00:00 heroku[web.1]: Process exited with status 1

Resources