Application error deploying my node.js project on Heroku - node.js

When running heroku --tail logs I get the following error response :
error:
2022-01-25T19:10:06.153750+00:00 app[web.1]: at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2022-01-25T19:10:06.153750+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2022-01-25T19:10:06.153751+00:00 app[web.1]: parent: Error: connect ECONNREFUSED 127.0.0.1:5432
2022-01-25T19:10:06.153751+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
2022-01-25T19:10:06.153751+00:00 app[web.1]: errno: -111,
2022-01-25T19:10:06.153751+00:00 app[web.1]: code: 'ECONNREFUSED',
2022-01-25T19:10:06.153751+00:00 app[web.1]: syscall: 'connect',
2022-01-25T19:10:06.153751+00:00 app[web.1]: address: '127.0.0.1',
2022-01-25T19:10:06.153752+00:00 app[web.1]: port: 5432
2022-01-25T19:10:06.153752+00:00 app[web.1]: },
2022-01-25T19:10:06.153752+00:00 app[web.1]: original: Error: connect ECONNREFUSED 127.0.0.1:5432
2022-01-25T19:10:06.153753+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
2022-01-25T19:10:06.153753+00:00 app[web.1]: errno: -111,
2022-01-25T19:10:06.153753+00:00 app[web.1]: code: 'ECONNREFUSED',
2022-01-25T19:10:06.153753+00:00 app[web.1]: syscall: 'connect',
2022-01-25T19:10:06.153753+00:00 app[web.1]: address: '127.0.0.1',
2022-01-25T19:10:06.153753+00:00 app[web.1]: port: 5432
2022-01-25T19:10:06.153754+00:00 app[web.1]: }
2022-01-25T19:10:06.153754+00:00 app[web.1]: }
2022-01-25T19:10:06.157055+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/novousuario" host=penedocrud.herokuapp.com request_id=c3ebdbb3-6831-493f-b8f1-8b02b051b0fd fwd="186.194.175.39" dyno=web.1 connect=0ms service=39ms status=503 bytes=0 protocol=https
2022-01-25T19:10:06.285294+00:00 heroku[web.1]: Process exited with status 1
2022-01-25T19:10:06.378171+00:00 heroku[web.1]: State changed from up to crashed
2022-01-25T19:10:06.394935+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-25T19:10:08.964699+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-25T19:10:10.224154+00:00 app[web.1]:
2022-01-25T19:10:10.224168+00:00 app[web.1]: > crud-tsnode#1.0.0 start
2022-01-25T19:10:10.224168+00:00 app[web.1]: > node dist/server.js
2022-01-25T19:10:10.224169+00:00 app[web.1]:
2022-01-25T19:10:10.850373+00:00 heroku[web.1]: State changed from starting to up
2022-01-25T19:14:21.409016+00:00 heroku[router]: at=info method=GET path="/" host=penedocrud.herokuapp.com request_id=d43d2faa-2dc7-4ccd-b0b0-6953fb887da1 fwd="177.223.108.63" dyno=web.1 connect=0ms service=16ms status=302 bytes=258 protocol=https
2022-01-25T19:14:21.565056+00:00 heroku[router]: at=info method=GET path="/cadastro" host=penedocrud.herokuapp.com request_id=631aaea8-c6eb-40b9-88d4-7443f498b302 fwd="177.223.108.63" dyno=web.1 connect=0ms service=14ms status=200 bytes=2021 protocol=https
2022-01-25T19:14:21.764188+00:00 heroku[router]: at=info method=GET path="/css/home.css" host=penedocrud.herokuapp.com request_id=ab9ebd5f-dc2e-49ae-af5f-7341971cd7ce fwd="177.223.108.63" dyno=web.1 connect=0ms service=5ms status=200 bytes=4576 protocol=https
2022-01-25T19:14:21.767993+00:00 heroku[router]: at=info method=GET path="/css/user.css" host=penedocrud.herokuapp.com request_id=733a9bbc-1ed0-44aa-9707-d0f92078c8eb fwd="177.223.108.63" dyno=web.1 connect=0ms service=6ms status=200 bytes=2997 protocol=https
2022-01-25T19:14:22.539670+00:00 heroku[router]: at=info method=GET path="/images/bcg.png" host=penedocrud.herokuapp.com request_id=11255b2d-cbc6-4dfe-a1e0-6c800951e32d fwd="177.223.108.63" dyno=web.1 connect=0ms service=5ms status=200 bytes=235792 protocol=https
2022-01-25T19:14:22.542372+00:00 heroku[router]: at=info method=GET path="/images/email.png" host=penedocrud.herokuapp.com request_id=bdcdd608-9f75-4f6d-a122-93c5ef6d82e5 fwd="177.223.108.63" dyno=web.1 connect=0ms service=5ms status=200 bytes=18008 protocol=https
2022-01-25T19:14:22.816037+00:00 heroku[router]: at=info method=GET path="/images/logo.png" host=penedocrud.herokuapp.com request_id=311d663c-c948-40cc-91c9-17ce7aa7911a fwd="177.223.108.63" dyno=web.1 connect=0ms service=2ms status=200 bytes=2388 protocol=https
2022-01-25T19:14:22.818541+00:00 heroku[router]: at=info method=GET path="/images/name.png" host=penedocrud.herokuapp.com request_id=d671647e-f942-4aea-a776-5832d2bee694 fwd="177.223.108.63" dyno=web.1 connect=0ms service=3ms status=200 bytes=12497 protocol=https
2022-01-25T19:14:22.825365+00:00 heroku[router]: at=info method=GET path="/images/age.png" host=penedocrud.herokuapp.com request_id=60241f72-2f73-4fe0-bd2f-952bf8f5a6d9 fwd="177.223.108.63" dyno=web.1 connect=0ms service=7ms status=200 bytes=16444 protocol=https
2022-01-25T19:49:47.981231+00:00 heroku[web.1]: Idling
2022-01-25T19:49:47.986454+00:00 heroku[web.1]: State changed from up to down
2022-01-25T19:49:50.160588+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2022-01-25T19:49:50.389620+00:00 heroku[web.1]: Process exited with status 143
2022-01-25T22:46:29.540970+00:00 heroku[web.1]: Unidling
2022-01-25T22:46:29.550645+00:00 heroku[web.1]: State changed from down to starting
2022-01-25T22:46:33.398737+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-25T22:46:34.700830+00:00 app[web.1]:
2022-01-25T22:46:34.700973+00:00 app[web.1]: > crud-tsnode#1.0.0 start
2022-01-25T22:46:34.700974+00:00 app[web.1]: > node dist/server.js
2022-01-25T22:46:34.700977+00:00 app[web.1]:
2022-01-25T22:46:35.247674+00:00 heroku[web.1]: State changed from starting to up
2022-01-25T22:46:36.627250+00:00 heroku[router]: at=info method=GET path="/" host=penedocrud.herokuapp.com request_id=1fec680e-4018-429b-976c-4fa723a293e8 fwd="186.194.175.39" dyno=web.1 connect=0ms service=16ms status=302 bytes=258 protocol=https
2022-01-25T22:46:36.788688+00:00 heroku[router]: at=info method=GET path="/cadastro" host=penedocrud.herokuapp.com request_id=2325bbd9-d70d-474f-8bfb-8fe51a07c60f fwd="186.194.175.39" dyno=web.1 connect=0ms service=8ms status=200 bytes=2021 protocol=https
2022-01-25T22:46:37.002494+00:00 heroku[router]: at=info method=GET path="/css/home.css" host=penedocrud.herokuapp.com request_id=c51796ed-faf1-401f-8670-3d57ee5130a2 fwd="186.194.175.39" dyno=web.1 connect=0ms service=6ms status=200 bytes=4576 protocol=https
2022-01-25T22:46:37.147871+00:00 heroku[router]: at=info method=GET path="/css/user.css" host=penedocrud.herokuapp.com request_id=d98f6cd2-064d-4dc2-84e6-a0ac83effa49 fwd="186.194.175.39" dyno=web.1 connect=0ms service=2ms status=304 bytes=237 protocol=https
2022-01-25T22:46:37.327082+00:00 heroku[router]: at=info method=GET path="/images/bcg.png" host=penedocrud.herokuapp.com request_id=e6766750-c7c3-4b5a-a9c6-c872d4af4bab fwd="186.194.175.39" dyno=web.1 connect=0ms service=5ms status=200 bytes=235792 protocol=https
2022-01-25T22:46:37.328041+00:00 heroku[router]: at=info method=GET path="/images/email.png" host=penedocrud.herokuapp.com request_id=306aceb2-9e0b-418e-b276-33479a270ad4 fwd="186.194.175.39" dyno=web.1 connect=0ms service=4ms status=200 bytes=18008 protocol=https
2022-01-25T22:46:37.582686+00:00 heroku[router]: at=info method=GET path="/images/name.png" host=penedocrud.herokuapp.com request_id=25b9cae2-fb7f-4e89-8a0b-3de030fb9391 fwd="186.194.175.39" dyno=web.1 connect=0ms service=3ms status=200 bytes=12497 protocol=https
2022-01-25T22:46:37.611328+00:00 heroku[router]: at=info method=GET path="/images/age.png" host=penedocrud.herokuapp.com request_id=912a75a1-f82a-4fea-99e0-c88eed20c88b fwd="186.194.175.39" dyno=web.1 connect=0ms service=2ms status=200 bytes=16444 protocol=https
2022-01-25T22:46:37.861955+00:00 heroku[router]: at=info method=GET path="/images/logo.png" host=penedocrud.herokuapp.com request_id=394eb964-0efa-4cc6-84e2-c1007629f51e fwd="186.194.175.39" dyno=web.1 connect=0ms service=2ms status=200 bytes=2388 protocol=https
2022-01-25T22:46:43.833799+00:00 app[web.1]: /app/node_modules/sequelize/dist/lib/dialects/postgres/connection-manager.js:130
2022-01-25T22:46:43.833826+00:00 app[web.1]: reject(new sequelizeErrors.ConnectionRefusedError(err));
2022-01-25T22:46:43.833827+00:00 app[web.1]: ^
2022-01-25T22:46:43.833827+00:00 app[web.1]:
2022-01-25T22:46:43.833827+00:00 app[web.1]: ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:5432
2022-01-25T22:46:43.833828+00:00 app[web.1]: at Client._connectionCallback (/app/node_modules/sequelize/dist/lib/dialects/postgres/connection-manager.js:130:24)
2022-01-25T22:46:43.833828+00:00 app[web.1]: at Client._handleErrorWhileConnecting (/app/node_modules/pg/lib/client.js:305:19)
2022-01-25T22:46:43.833829+00:00 app[web.1]: at Client._handleErrorEvent (/app/node_modules/pg/lib/client.js:315:19)
2022-01-25T22:46:43.833829+00:00 app[web.1]: at Connection.emit (node:events:390:28)
2022-01-25T22:46:43.833830+00:00 app[web.1]: at Socket.reportStreamError (/app/node_modules/pg/lib/connection.js:52:12)
2022-01-25T22:46:43.833830+00:00 app[web.1]: at Socket.emit (node:events:390:28)
2022-01-25T22:46:43.833830+00:00 app[web.1]: at emitErrorNT (node:internal/streams/destroy:157:8)
2022-01-25T22:46:43.833831+00:00 app[web.1]: at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2022-01-25T22:46:43.833831+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2022-01-25T22:46:43.833831+00:00 app[web.1]: parent: Error: connect ECONNREFUSED 127.0.0.1:5432
2022-01-25T22:46:43.833831+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
2022-01-25T22:46:43.833832+00:00 app[web.1]: errno: -111,
2022-01-25T22:46:43.833832+00:00 app[web.1]: code: 'ECONNREFUSED',
2022-01-25T22:46:43.833832+00:00 app[web.1]: syscall: 'connect',
2022-01-25T22:46:43.833833+00:00 app[web.1]: address: '127.0.0.1',
2022-01-25T22:46:43.833833+00:00 app[web.1]: port: 5432
2022-01-25T22:46:43.833833+00:00 app[web.1]: },
2022-01-25T22:46:43.833834+00:00 app[web.1]: original: Error: connect ECONNREFUSED 127.0.0.1:5432
2022-01-25T22:46:43.833834+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
2022-01-25T22:46:43.833834+00:00 app[web.1]: errno: -111,
2022-01-25T22:46:43.833834+00:00 app[web.1]: code: 'ECONNREFUSED',
2022-01-25T22:46:43.833835+00:00 app[web.1]: syscall: 'connect',
2022-01-25T22:46:43.833835+00:00 app[web.1]: address: '127.0.0.1',
2022-01-25T22:46:43.833835+00:00 app[web.1]: port: 5432
2022-01-25T22:46:43.833835+00:00 app[web.1]: }
2022-01-25T22:46:43.833835+00:00 app[web.1]: }
2022-01-25T22:46:43.841412+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/novousuario" host=penedocrud.herokuapp.com request_id=0b79d914-ec57-42c9-ab36-d274157b9913 fwd="186.194.175.39" dyno=web.1 connect=0ms service=393ms status=503 bytes=0 protocol=https
2022-01-25T22:46:44.010251+00:00 heroku[web.1]: Process exited with status 1
2022-01-25T22:46:44.064573+00:00 heroku[web.1]: State changed from up to crashed
2022-01-25T22:46:44.068523+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-25T22:46:47.824479+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-25T22:46:48.950210+00:00 app[web.1]:
2022-01-25T22:46:48.950226+00:00 app[web.1]: > crud-tsnode#1.0.0 start
2022-01-25T22:46:48.950227+00:00 app[web.1]: > node dist/server.js
2022-01-25T22:46:48.950227+00:00 app[web.1]:
2022-01-25T22:46:49.481570+00:00 heroku[web.1]: State changed from starting to up
Here is my server.ts file:
import express, { Request, Response } from 'express';
import path from 'path';
import mustache from 'mustache-express';
import dotenv from 'dotenv';
import mainRoutes from './routes/index';
dotenv.config();
const server = express();
server.set('view engine', 'mustache');
server.set('views', path.join(__dirname, 'views'));
server.engine('mustache', mustache());
server.use(express.static(path.join(__dirname, '../public')));
server.use(express.urlencoded({extended: true}));
server.use(mainRoutes);
server.use((req: Request, res: Response)=>{
res.status(404).render('pages/404')
});
server.listen(process.env.PORT);
my routes:
import { Router } from "express";
import * as HomeController from '../controllers/homeController'
import * as UserController from '../controllers/userController'
import * as SearchController from '../controllers/searchController'
const router = Router()
router.get('/', HomeController.home)
router.get('/cadastro', HomeController.register)
router.get('/usuarios', UserController.users)
router.post('/novousuario', UserController.newUser)
router.get('/usuario/:id/editar', UserController.editUser)
router.get('/usuario/:id/excluir', UserController.deleteUser)
router.post('/novousuarioeditado/:id', UserController.newEditUser)
router.get('/search', SearchController.search)
export default router
looking through the browser it shows the error 503, there seems to be something wrong with the routes, when registering in the CRUD app, it should request the POST route and immediately redirect it to the users, but it simply gives an error in the application
remembering that everything is working locally, with no apparent errors
and , here is my package.json file:
{
"name": "crud-tsnode",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "16.x"
},
"scripts": {
"start": "node dist/server.js",
"tsc": "tsc",
"postinstall": "npm run tsc && copyfiles -u 1 src/**/*.mustache dist/",
"test": "echo \"Error: no test specified\" && exit 1",
"start-dev": "nodemon -e ts,json,mustache src/server.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/FabioPenedo/Crud-tsnode.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/FabioPenedo/Crud-tsnode/issues"
},
"homepage": "https://github.com/FabioPenedo/Crud-tsnode#readme",
"dependencies": {
"dotenv": "^14.2.0",
"express": "^4.17.2",
"mustache-express": "^1.3.2",
"pg": "^8.7.1",
"pg-hstore": "^2.3.4",
"sequelize": "^6.13.0",
"typescript": "^4.5.5"
},
"devDependencies": {
"#types/express": "^4.17.13",
"#types/mustache-express": "^1.2.1",
"#types/node": "^17.0.10",
"#types/sequelize": "^4.28.11",
"copyfiles": "^2.4.1"
}
}

Port 5432 hints that your program is trying to connect to postgreSQL on localhost. That's probably the way it works in development on your own machine.
But, on Heroku your postgreSQL server is not on the same machine as your web dyno, so connecting to localhost:5432 does not work. The econnrefused error comes from the operating system, and it says that nothing is running on the port you tried to connect to.
Heroku, when you provision a postgreSQL database instance, gives you an environment variable called DATABASE_URL that's available to your app. You should use that to connect to your database.

Related

Heroku gives "Connection closed without response" error when trying to use https

I've created a single page app using the PERN stack and have successfully deployed it to Heroku. Now I am trying to switch to https on the backend, and have creaed a selfsigned.crt file and a selfsigned.key file, but I can't figure out this current error.
Here's my db.js
let connectionString = {
connectionString:
process.env.DATABASE_URL,
ssl: true,
};
const pool = new Pool(connectionString);
module.exports = pool;
Here's my server.js
const express = require("express");
const app = express();
const fs = require("fs");
const https = require("https");
const httpsPort = process.env.PORT || 8443;
const privateKey = fs.readFileSync("./sslCertification/selfsigned.key", "utf8");
const certificate = fs.readFileSync("./sslCertification/selfsigned.crt", "utf8");
const credentials = { key: privateKey, cert: certificate };
const priorityStatus = require("./routes/priorityStatus");
const accounts = require("./routes/accounts");
const projects = require("./routes/projects");
const bugs = require("./routes/bugs");
const comments = require("./routes/comments");
app.use(express.json());
app.all('*', function(req, res, next) {
if (req.headers['x-forwarded-proto'] != 'https')
res.redirect('https://' + req.headers.host + req.url)
else
next()
});
// Needed since single page application
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
}
app.get('*', (request, response) => {
response.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
app.use("/api/priority-status", priorityStatus);
app.use("/api/account", accounts);
app.use("/api/project", projects);
app.use("/api/bug", bugs);
app.use("/api/comment", comments);
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(httpsPort);
// Was using this before switching to https
/* app.listen(process.env.PORT || 5000, () => {
console.log("Server has started on port 5000");
}); */
Here's what I get in my Heroku log --tail.
2020-12-16T23:45:25.843470+00:00 app[web.1]: [1] > server#1.0.0 client /app
2020-12-16T23:45:25.843471+00:00 app[web.1]: [1] > npm start --prefix ./client
2020-12-16T23:45:25.843472+00:00 app[web.1]: [1]
2020-12-16T23:45:26.287947+00:00 app[web.1]: [0]
2020-12-16T23:45:26.287959+00:00 app[web.1]: [0] > server#1.0.0 server /app
2020-12-16T23:45:26.287960+00:00 app[web.1]: [0] > npm start server.js
2020-12-16T23:45:26.287960+00:00 app[web.1]: [0]
2020-12-16T23:45:27.261503+00:00 app[web.1]: [1]
2020-12-16T23:45:27.261511+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2020-12-16T23:45:27.261512+00:00 app[web.1]: [1] > react-scripts start
2020-12-16T23:45:27.261512+00:00 app[web.1]: [1]
2020-12-16T23:45:27.287963+00:00 app[web.1]: [0]
2020-12-16T23:45:27.287965+00:00 app[web.1]: [0] > server#1.0.0 start /app
2020-12-16T23:45:27.287966+00:00 app[web.1]: [0] > node server.js "server.js"
2020-12-16T23:45:27.287966+00:00 app[web.1]: [0]
2020-12-16T23:45:29.329961+00:00 app[web.1]: [0] Server has started on port 5000
2020-12-16T23:45:29.377253+00:00 heroku[web.1]: State changed from starting to up
2020-12-16T23:45:31.082924+00:00 heroku[router]: at=info method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=d77f6dfd-b5e2-4f8c-b5ec-6c8ca90063dd fwd="107.181.184.23" dyno=web.1 connect=1ms service=62ms status=200 bytes=2573 protocol=https
2020-12-16T23:45:31.327977+00:00 heroku[router]: at=info method=GET path="/static/js/main.627d6695.chunk.js" host=my-bug-tracker.herokuapp.com request_id=3e09e810-ba9b-4ffc-80ec-1452b4dc3fde fwd="107.181.184.23" dyno=web.1 connect=0ms service=8ms status=200 bytes=118886 protocol=https
2020-12-16T23:45:31.580398+00:00 heroku[router]: at=info method=GET path="/static/css/2.e6f51e71.chunk.css" host=my-bug-tracker.herokuapp.com request_id=fd127936-041d-4621-8417-4ab61d3be700 fwd="107.181.184.23" dyno=web.1 connect=1ms service=5ms status=200 bytes=30948 protocol=https
2020-12-16T23:45:31.766225+00:00 heroku[router]: at=info method=GET path="/static/css/main.baebc1a0.chunk.css" host=my-bug-tracker.herokuapp.com request_id=0cbed062-cc5a-4b0b-a5b5-9e0c6c126411 fwd="107.181.184.23" dyno=web.1 connect=0ms service=33ms status=200 bytes=51828 protocol=https
2020-12-16T23:45:31.800991+00:00 heroku[router]: at=info method=GET path="/static/js/2.86007984.chunk.js" host=my-bug-tracker.herokuapp.com request_id=4cb8b8f0-7a9f-4d19-b5e7-886956ff367b fwd="107.181.184.23" dyno=web.1 connect=0ms service=17ms status=200 bytes=256970 protocol=https
2020-12-16T23:45:32.395277+00:00 heroku[router]: at=info method=GET path="/static/media/BlueBackground_1920.f1fd53eb.jpg" host=my-bug-tracker.herokuapp.com request_id=fec9221a-2535-4a31-aa23-faae29fd9278 fwd="107.181.184.23" dyno=web.1 connect=0ms service=79ms status=200 bytes=193680 protocol=https
2020-12-16T23:45:32.435799+00:00 heroku[router]: at=info method=GET path="/bug-icon-white-background-thick.ico" host=my-bug-tracker.herokuapp.com request_id=2c3fcb80-9d59-4e2d-82cb-e40e069572fc fwd="107.181.184.23" dyno=web.1 connect=0ms service=11ms status=200 bytes=14451 protocol=https
2020-12-16T23:45:34.651092+00:00 app[web.1]: [1] Something is already running on port 32518.
2020-12-16T23:45:34.713739+00:00 app[web.1]: [1] npm run client exited with code 0
2020-12-16T23:45:38.231748+00:00 heroku[router]: at=info method=POST path="/api/account/login" host=my-bug-tracker.herokuapp.com request_id=a98b5798-90c0-43d5-951e-9eedb3caf308 fwd="107.181.184.23" dyno=web.1 connect=0ms service=365ms status=200 bytes=18030 protocol=https
2020-12-16T23:45:38.468324+00:00 heroku[router]: at=info method=GET path="/static/media/sort-arrows-both-empty.4823f7dd.svg" host=my-bug-tracker.herokuapp.com request_id=5ac2ebe3-eade-4929-ac13-a9c130ee49ba fwd="107.181.184.23" dyno=web.1 connect=0ms service=9ms status=200 bytes=2668 protocol=https
2020-12-16T23:45:38.469210+00:00 heroku[router]: at=info method=GET path="/static/media/sort-arrows-top-filled.d4ef80d2.svg" host=my-bug-tracker.herokuapp.com request_id=86e2dc2d-3cbd-49f3-9bff-d0318bfd88e6 fwd="107.181.184.23" dyno=web.1 connect=0ms service=10ms status=200 bytes=2700 protocol=https
2020-12-16T23:45:38.508359+00:00 heroku[router]: at=info method=GET path="/static/media/fontawesome-webfont.af7ae505.woff2" host=my-bug-tracker.herokuapp.com request_id=1c3618aa-6c2d-4849-9742-40b7cf76c25e fwd="107.181.184.23" dyno=web.1 connect=1ms service=10ms status=200 bytes=77438 protocol=https
2020-12-16T23:46:24.944613+00:00 heroku[router]: at=info method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=0825b13a-7917-43d4-bcd9-c0c96df2dc06 fwd="107.181.184.23" dyno=web.1 connect=0ms service=3ms status=304 bytes=237 protocol=https
2020-12-16T23:46:25.177238+00:00 heroku[router]: at=info method=GET path="/static/css/2.e6f51e71.chunk.css" host=my-bug-tracker.herokuapp.com request_id=24c6a746-e906-49db-83ce-ccbe39a274ab fwd="107.181.184.23" dyno=web.1 connect=0ms service=4ms status=200 bytes=30948 protocol=https
2020-12-16T23:46:25.179901+00:00 heroku[router]: at=info method=GET path="/static/css/main.baebc1a0.chunk.css" host=my-bug-tracker.herokuapp.com request_id=d88baeaf-45ac-44fa-8e36-8b4a513c0e9f fwd="107.181.184.23" dyno=web.1 connect=1ms service=7ms status=200 bytes=51828 protocol=https
2020-12-16T23:46:25.184930+00:00 heroku[router]: at=info method=GET path="/static/js/2.86007984.chunk.js" host=my-bug-tracker.herokuapp.com request_id=23923f21-2b35-4eae-9ec4-a5bb511f7fc9 fwd="107.181.184.23" dyno=web.1 connect=0ms service=2ms status=304 bytes=239 protocol=https
2020-12-16T23:46:25.674846+00:00 heroku[router]: at=info method=GET path="/static/js/main.627d6695.chunk.js" host=my-bug-tracker.herokuapp.com request_id=92de810a-64b1-4723-ade4-f3af20f16914 fwd="107.181.184.23" dyno=web.1 connect=0ms service=2ms status=304 bytes=239 protocol=https
2020-12-16T23:46:25.895205+00:00 heroku[router]: at=info method=GET path="/static/media/BlueBackground_1920.f1fd53eb.jpg" host=my-bug-tracker.herokuapp.com request_id=8120bdf0-664b-42a5-9466-47ff254605e0 fwd="107.181.184.23" dyno=web.1 connect=0ms service=14ms status=200 bytes=193680 protocol=https
2020-12-16T23:46:26.005483+00:00 heroku[router]: at=info method=GET path="/bug-icon-white-background-thick.ico" host=my-bug-tracker.herokuapp.com request_id=6d37a9df-6bad-44c6-bf4c-4871036094b0 fwd="107.181.184.23" dyno=web.1 connect=1ms service=5ms status=200 bytes=14451 protocol=https
2020-12-17T00:17:57.035580+00:00 heroku[web.1]: Idling
2020-12-17T00:17:57.038063+00:00 heroku[web.1]: State changed from up to down
2020-12-17T00:17:58.600226+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-12-17T00:17:58.725162+00:00 heroku[web.1]: Process exited with status 143
2020-12-19T00:16:45.000000+00:00 app[api]: Build started by user myemail#outlook.com
2020-12-19T00:18:36.760218+00:00 app[api]: Release v32 created by user myemail#outlook.com
2020-12-19T00:18:36.760218+00:00 app[api]: Deploy a56a8d74 by user myemail#outlook.com
2020-12-19T00:18:37.085799+00:00 heroku[web.1]: State changed from down to starting
2020-12-19T00:18:38.000000+00:00 app[api]: Build succeeded
2020-12-19T00:18:46.854143+00:00 heroku[web.1]: Starting process with command `npm run dev`
2020-12-19T00:18:49.111701+00:00 app[web.1]:
2020-12-19T00:18:49.111720+00:00 app[web.1]: > server#1.0.0 dev /app
2020-12-19T00:18:49.111721+00:00 app[web.1]: > concurrently "npm run server" "npm run client"
2020-12-19T00:18:49.111721+00:00 app[web.1]:
2020-12-19T00:18:50.371711+00:00 app[web.1]: [0]
2020-12-19T00:18:50.371740+00:00 app[web.1]: [0] > server#1.0.0 server /app
2020-12-19T00:18:50.371741+00:00 app[web.1]: [0] > npm start server.js
2020-12-19T00:18:50.371741+00:00 app[web.1]: [0]
2020-12-19T00:18:50.685530+00:00 app[web.1]: [1]
2020-12-19T00:18:50.685542+00:00 app[web.1]: [1] > server#1.0.0 client /app
2020-12-19T00:18:50.685542+00:00 app[web.1]: [1] > npm start --prefix ./client
2020-12-19T00:18:50.685543+00:00 app[web.1]: [1]
2020-12-19T00:18:50.962753+00:00 app[web.1]: [0]
2020-12-19T00:18:50.962763+00:00 app[web.1]: [0] > server#1.0.0 start /app
2020-12-19T00:18:50.962764+00:00 app[web.1]: [0] > node server.js "server.js"
2020-12-19T00:18:50.962764+00:00 app[web.1]: [0]
2020-12-19T00:18:51.591232+00:00 heroku[web.1]: State changed from starting to up
2020-12-19T00:18:52.237451+00:00 app[web.1]: [1]
2020-12-19T00:18:52.237462+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2020-12-19T00:18:52.237463+00:00 app[web.1]: [1] > react-scripts start
2020-12-19T00:18:52.237464+00:00 app[web.1]: [1]
2020-12-19T00:18:54.475128+00:00 app[web.1]: [1] Something is already running on port 36160.
2020-12-19T00:18:54.500055+00:00 app[web.1]: [1] npm run client exited with code 0
2020-12-19T00:21:30.162248+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=d2dde696-e905-4999-b060-8f55e67638f8 fwd="73.133.94.85" dyno=web.1 connect=1ms service=8ms status=503 bytes=0 protocol=https
2020-12-19T00:23:04.490925+00:00 heroku[web.1]: Restarting
2020-12-19T00:23:04.507527+00:00 heroku[web.1]: State changed from up to starting
2020-12-19T00:23:05.356455+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-12-19T00:23:05.438828+00:00 heroku[web.1]: Process exited with status 143
2020-12-19T00:23:17.170024+00:00 heroku[web.1]: Starting process with command `npm run dev`
2020-12-19T00:23:20.333801+00:00 app[web.1]:
2020-12-19T00:23:20.333826+00:00 app[web.1]: > server#1.0.0 dev /app
2020-12-19T00:23:20.333827+00:00 app[web.1]: > concurrently "npm run server" "npm run client"
2020-12-19T00:23:20.333827+00:00 app[web.1]:
2020-12-19T00:23:21.436851+00:00 app[web.1]: [0]
2020-12-19T00:23:21.436873+00:00 app[web.1]: [0] > server#1.0.0 server /app
2020-12-19T00:23:21.436873+00:00 app[web.1]: [0] > npm start server.js
2020-12-19T00:23:21.436874+00:00 app[web.1]: [0]
2020-12-19T00:23:21.498752+00:00 app[web.1]: [1]
2020-12-19T00:23:21.498754+00:00 app[web.1]: [1] > server#1.0.0 client /app
2020-12-19T00:23:21.498754+00:00 app[web.1]: [1] > npm start --prefix ./client
2020-12-19T00:23:21.498755+00:00 app[web.1]: [1]
2020-12-19T00:23:22.064333+00:00 app[web.1]: [1]
2020-12-19T00:23:22.064355+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2020-12-19T00:23:22.064356+00:00 app[web.1]: [1] > react-scripts start
2020-12-19T00:23:22.064356+00:00 app[web.1]: [1]
2020-12-19T00:23:22.116724+00:00 app[web.1]: [0]
2020-12-19T00:23:22.116727+00:00 app[web.1]: [0] > server#1.0.0 start /app
2020-12-19T00:23:22.116729+00:00 app[web.1]: [0] > node server.js "server.js"
2020-12-19T00:23:22.116729+00:00 app[web.1]: [0]
2020-12-19T00:23:23.302719+00:00 heroku[web.1]: State changed from starting to up
2020-12-19T00:23:24.037351+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=6c715c5a-4f70-4e16-8a4c-307adb441f0a fwd="73.133.94.85" dyno=web.1 connect=1ms service=5ms status=503 bytes=0 protocol=https
2020-12-19T00:23:24.579638+00:00 app[web.1]: [1] Something is already running on port 9268.
2020-12-19T00:23:24.631826+00:00 app[web.1]: [1] npm run client exited with code 0

Open Weather API Heroku worked fine on local system but crashes on Heroku

I am using open weather api. On my local system I used this request and it worked fine.
"http://api.openweathermap.org/data/2.5/weather?lat="+lattitude+"&lon="+longitude+"&appid="+weatherKey+"&units="+unit"
Then I searched solution for this problem online and modified the request as:
https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?lat="+lattitude+"&lon="+longitude+"&appid="+weatherKey+"&units="+unit
Honestky I dont know why we are using "https://cors-anywhere.herokuapp.com" .I would be glad if somebody explained the meaning.
I am still getting an error.Please help me.Thanks in advance.
herku log
Server started on port 3000
2020-08-10T11:40:06.567155+00:00 heroku[web.1]: State changed from starting to up
2020-08-10T11:40:10.839569+00:00 heroku[router]: at=info method=GET path="/" host=news-with-tea.herokuapp.com request_id=03988840-7db9-47b6-a22d-5aa10d525a59 fwd="49.205.248.228" dyno=web.1 connect=1ms service=653ms status=304 bytes=184 protocol=https
2020-08-10T11:40:11.865181+00:00 heroku[router]: at=info method=GET path="/css/styles.css" host=news-with-tea.herokuapp.com request_id=e4b7fc2c-55b4-41f8-82fe-37eb7f2bb710 fwd="49.205.248.228" dyno=web.1 connect=0ms service=6ms status=200 bytes=2033 protocol=https
2020-08-10T11:40:11.931225+00:00 heroku[router]: at=info method=GET path="/weather.js" host=news-with-tea.herokuapp.com request_id=6c6b0987-9f84-4ea7-b32d-563c0cee6596 fwd="49.205.248.228" dyno=web.1 connect=0ms service=10ms status=200 bytes=3968 protocol=https
2020-08-10T11:40:12.265807+00:00 heroku[router]: at=info method=GET path="/weather.js" host=news-with-tea.herokuapp.com request_id=f08b5be2-1c62-4f69-9193-1e32494490ab fwd="49.205.248.228" dyno=web.1 connect=0ms service=2ms status=304 bytes=237 protocol=https
2020-08-10T11:40:27.640043+00:00 app[web.1]: helllo[object Object]
2020-08-10T11:40:29.742161+00:00 app[web.1]: 17 78
2020-08-10T11:40:30.245240+00:00 app[web.1]: undefined:1
2020-08-10T11:40:30.245258+00:00 app[web.1]: Missing required request header. Must specify one of: origin,x-requested-with
2020-08-10T11:40:30.245258+00:00 app[web.1]: ^
2020-08-10T11:40:30.245258+00:00 app[web.1]:
2020-08-10T11:40:30.245259+00:00 app[web.1]: SyntaxError: Unexpected token M in JSON at position 0
2020-08-10T11:40:30.245260+00:00 app[web.1]: at JSON.parse (<anonymous>)
2020-08-10T11:40:30.245260+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/app.js:137:29)
2020-08-10T11:40:30.245261+00:00 app[web.1]: at IncomingMessage.emit (events.js:315:20)
2020-08-10T11:40:30.245261+00:00 app[web.1]: at addChunk (_stream_readable.js:295:12)
2020-08-10T11:40:30.245262+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:271:9)
2020-08-10T11:40:30.245262+00:00 app[web.1]: at IncomingMessage.Readable.push (_stream_readable.js:212:10)
2020-08-10T11:40:30.245263+00:00 app[web.1]: at HTTPParser.parserOnBody (_http_common.js:132:24)
2020-08-10T11:40:30.245263+00:00 app[web.1]: at TLSSocket.socketOnData (_http_client.js:469:22)
2020-08-10T11:40:30.245263+00:00 app[web.1]: at TLSSocket.emit (events.js:315:20)
2020-08-10T11:40:30.245264+00:00 app[web.1]: at addChunk (_stream_readable.js:295:12)
2020-08-10T11:40:30.252437+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/weather" host=news-with-tea.herokuapp.com request_id=c9e29b82-7b67-4af0-9746-a118f77c69e7 fwd="49.205.248.228" dyno=web.1 connect=0ms service=511ms status=503 bytes=0 protocol=https
2020-08-10T11:40:30.252876+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/weather" host=news-with-tea.herokuapp.com request_id=a54e7548-a500-410a-8817-31e38dc20a2b fwd="49.205.248.228" dyno=web.1 connect=0ms service=2629ms status=503 bytes=0 protocol=https
2020-08-10T11:40:30.257162+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-10T11:40:30.257415+00:00 app[web.1]: npm ERR! errno 1
2020-08-10T11:40:30.259890+00:00 app[web.1]: npm ERR! ejs-challenge#1.0.0 start: `node app.js`
2020-08-10T11:40:30.260001+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-10T11:40:30.260127+00:00 app[web.1]: npm ERR!
2020-08-10T11:40:30.260237+00:00 app[web.1]: npm ERR! Failed at the ejs-challenge#1.0.0 start script.
2020-08-10T11:40:30.260419+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-10T11:40:30.271263+00:00 app[web.1]:
2020-08-10T11:40:30.271644+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-10T11:40:30.271681+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-10T11_40_30_261Z-debug.log
2020-08-10T11:40:30.361346+00:00 heroku[web.1]: Process exited with status 1
2020-08-10T11:40:30.404906+00:00 heroku[web.1]: State changed from up to crashed
2020-08-10T11:45:24.731721+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=news-with-tea.herokuapp.com request_id=0b2f6496-cba4-40ea-94b1-d4de70aab61a fwd="49.205.248.228" dyno= connect= service= status=503 bytes= protocol=https
2020-08-10T11:45:24.969535+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=news-with-tea.herokuapp.com request_id=5f1db2b1-b242-4c8c-9541-4cf19dd486ed fwd="49.205.248.228" dyno= connect= service= status=503 bytes= protocol=https
2020-08-10T11:45:29.819254+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=news-with-tea.herokuapp.com request_id=3a5fed80-b456-452e-86bc-b47dd644f2b6 fwd="49.205.248.228" dyno= connect= service= status=503 bytes= protocol=https
2020-08-10T11:48:09.750615+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-10T11:48:12.239984+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-10T11:48:14.253874+00:00 app[web.1]:
2020-08-10T11:48:14.253897+00:00 app[web.1]: > ejs-challenge#1.0.0 start /app
2020-08-10T11:48:14.253898+00:00 app[web.1]: > node app.js
2020-08-10T11:48:14.253898+00:00 app[web.1]:
2020-08-10T11:48:14.441205+00:00 app[web.1]: Server started on port 3000
2020-08-10T11:48:14.541655+00:00 heroku[web.1]: State changed from starting to up
app.get('/weather',function(req,res){
const unit="metric";
const url="https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?lat="+lattitude+"&lon="+longitude+"&appid="+weatherKey+"&units="+unit;
https.get(url,function(response){
response.on("data",function(data){
// convert data into JSON object
const weatherData= JSON.parse(data);
console.log(weatherData);
const id=weatherData.weather[0].id;
res.render('weather',{weatherData:weatherData,id:id});
})
})
});
You don't need to use "https://cors-anywhere.herokuapp.com/", the API doesn't differentiate between your local request or a request coming from an heroku server.

Why does my Heroku API app not return json data?

I created a Node.js, Express, PostgreSQL API and hosted it on Heroku. After pushing it to Heroku, I am able to see the home page but when I go to the /colors route I don't get any data. Any help you can give me in figuring this problem out would help.
Here is a link to the site and repo.
Logs:
2020-06-17T03:15:01.217602+00:00 heroku[web.1]: Process exited with status 143
2020-06-17T03:15:02.439787+00:00 heroku[web.1]: Starting process with command `node server.js`
2020-06-17T03:15:05.313847+00:00 app[web.1]: Server started on: 32495.
2020-06-17T03:15:05.784686+00:00 heroku[web.1]: State changed from starting to up
2020-06-17T03:15:18.042530+00:00 heroku[router]: at=info method=GET path="/colors" host=api-colors.herokuapp.com request_id=6196ed32-f423-4602-ad3d-ce126e91dfeb fwd="73.131.85.220" dyno=web.1 connect=0ms service=58ms status=500 bytes=744 protocol=https
2020-06-17T03:15:18.046053+00:00 app[web.1]: Error: self signed certificate
2020-06-17T03:15:18.046095+00:00 app[web.1]: at TLSSocket.onConnectSecure (_tls_wrap.js:1506:34)
2020-06-17T03:15:18.046096+00:00 app[web.1]: at TLSSocket.emit (events.js:315:20)
2020-06-17T03:15:18.046096+00:00 app[web.1]: at TLSSocket._finishInit (_tls_wrap.js:948:8)
2020-06-17T03:15:18.046097+00:00 app[web.1]: at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12)
2020-06-17T03:15:47.081186+00:00 heroku[router]: at=info method=GET path="/" host=api-colors.herokuapp.com request_id=3cc79d25-b300-4c65-a667-62ff18d75592 fwd="73.131.85.220" dyno=web.1 connect=0ms service=7ms status=200 bytes=869 protocol=https
2020-06-17T03:16:30.773456+00:00 heroku[router]: at=info method=GET path="/" host=api-colors.herokuapp.com request_id=89237876-0288-476e-8f3c-be1c8f692d10 fwd="73.131.85.220" dyno=web.1 connect=0ms service=3ms status=304 bytes=592 protocol=https
2020-06-17T03:18:03.112837+00:00 heroku[router]: at=info method=GET path="/" host=api-colors.herokuapp.com request_id=eaf8785d-5f32-4aaf-a2e9-6077be7f9df5 fwd="73.131.85.220" dyno=web.1 connect=0ms service=3ms status=304 bytes=592 protocol=https
2020-06-17T03:18:05.473221+00:00 heroku[router]: at=info method=GET path="/" host=api-colors.herokuapp.com request_id=e8ad5819-21d1-4779-aa8c-2a2e722913c8 fwd="73.131.85.220" dyno=web.1 connect=0ms service=2ms status=304 bytes=592 protocol=https
2020-06-17T03:18:18.755366+00:00 app[web.1]: Error: self signed certificate
2020-06-17T03:18:18.755384+00:00 app[web.1]: at TLSSocket.onConnectSecure (_tls_wrap.js:1506:34)
2020-06-17T03:18:18.755385+00:00 app[web.1]: at TLSSocket.emit (events.js:315:20)
2020-06-17T03:18:18.755385+00:00 app[web.1]: at TLSSocket._finishInit (_tls_wrap.js:948:8)
2020-06-17T03:18:18.755386+00:00 app[web.1]: at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12)
2020-06-17T03:18:18.753356+00:00 heroku[router]: at=info method=GET path="/colors" host=api-colors.herokuapp.com request_id=c8966ce9-76bf-4f67-abae-24008433c025 fwd="73.131.85.220" dyno=web.1 connect=1ms service=14ms status=500 bytes=744 protocol=https

Unable to add my database postgresql on heroku nodejs DEPLOYMENT ERROR

const express = require ('express');
const bodyParser = require('body-parser');
var passwordHash = require('password-hash');
const cors = require('cors');
var knex = require('knex');
const register = require('./controllers/Register');
const signin = require('./controllers/Signin');
const profile = require('./controllers/Profile');
const image = require('./controllers/Image');
//var connectionString = "postgres://*USERNAME*:*PASSWORD*#*HOST*:*PORT*/*DATABASE*"
const db = knex({
client: 'pg',
connection: {
connectionString: process.env.DATABASE_URL,
ssl: true,
}
})
const app=express();
app.use(bodyParser.json());
app.use(cors());
app.get('/',(req, res)=>{
res.send("it is working")
})
app.post('/signin',(req,res)=>{signin.handleSignIn(req,res,db,passwordHash)})
app.post('/register',(req, res)=>{register.handleRegister(req, res, db,passwordHash)})
app.get('/profile/:id', (req,res)=>{profile.handleProfileGet(req,res,db)})
app.put('/image',(req,res)=>{image.handleImage(req,res,db)})
app.post('/imageurl',(req,res)=>{image.handleApiCall(req,res)})
app.listen(process.env.PORT || 3000, ()=>{
console.log(`app is running on port ${process.env.PORT}`)
})
This is my server.js file
unable to figure out error I added all the changes using git add then used git commit -m "changed port" git push heroku master
git logs --tail (getting error here)
rohit#rohit-Vostro-3583:~/Desktop/smartbrainAPI$ heroku logs --tail
2020-04-19T11:38:00.460877+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-19T11:38:04.722372+00:00 app[web.1]:
2020-04-19T11:38:04.722404+00:00 app[web.1]: > node#1.0.0 start /app
2020-04-19T11:38:04.722404+00:00 app[web.1]: > node server.js
2020-04-19T11:38:04.722405+00:00 app[web.1]:
2020-04-19T11:38:05.064464+00:00 app[web.1]: /app/server.js:21
2020-04-19T11:38:05.064499+00:00 app[web.1]: db.connect();
2020-04-19T11:38:05.064500+00:00 app[web.1]: ^
2020-04-19T11:38:05.064500+00:00 app[web.1]:
2020-04-19T11:38:05.064504+00:00 app[web.1]: TypeError: db.connect is not a function
2020-04-19T11:38:05.064505+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:21:6)
2020-04-19T11:38:05.064506+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1156:30)
2020-04-19T11:38:05.064506+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
2020-04-19T11:38:05.064506+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1000:32)
2020-04-19T11:38:05.064507+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:899:14)
2020-04-19T11:38:05.064507+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
2020-04-19T11:38:05.064508+00:00 app[web.1]: at internal/main/run_main_module.js:18:47
2020-04-19T11:38:05.070768+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-04-19T11:38:05.071050+00:00 app[web.1]: npm ERR! errno 1
2020-04-19T11:38:05.072100+00:00 app[web.1]: npm ERR! node#1.0.0 start: `node server.js`
2020-04-19T11:38:05.072245+00:00 app[web.1]: npm ERR! Exit status 1
2020-04-19T11:38:05.072422+00:00 app[web.1]: npm ERR!
2020-04-19T11:38:05.072557+00:00 app[web.1]: npm ERR! Failed at the node#1.0.0 start script.
2020-04-19T11:38:05.072688+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-04-19T11:38:05.077328+00:00 app[web.1]:
2020-04-19T11:38:05.077531+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-04-19T11:38:05.077662+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-04-19T11_38_05_073Z-debug.log
2020-04-19T11:38:05.151564+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-19T11:39:03.000000+00:00 app[api]: Build started by user rohitjain991100#gmail.com
2020-04-19T11:39:26.226816+00:00 app[api]: Deploy cf844469 by user rohitjain991100#gmail.com
2020-04-19T11:39:26.226816+00:00 app[api]: Release v20 created by user rohitjain991100#gmail.com
2020-04-19T11:39:26.932529+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-19T11:39:27.000000+00:00 app[api]: Build succeeded
2020-04-19T11:39:34.492601+00:00 app[web.1]:
2020-04-19T11:39:34.492681+00:00 app[web.1]: > node#1.0.0 start /app
2020-04-19T11:39:34.492682+00:00 app[web.1]: > node server.js
2020-04-19T11:39:34.492683+00:00 app[web.1]:
2020-04-19T11:39:35.127798+00:00 heroku[web.1]: State changed from starting to up
2020-04-19T11:39:35.085705+00:00 app[web.1]: app is running on port 31626
2020-04-19T11:53:00.000000+00:00 app[api]: Build started by user rohitjain991100#gmail.com
2020-04-19T11:53:22.454500+00:00 heroku[web.1]: Restarting
2020-04-19T11:53:22.458236+00:00 heroku[web.1]: State changed from up to starting
2020-04-19T11:53:22.256081+00:00 app[api]: Release v21 created by user rohitjain991100#gmail.com
2020-04-19T11:53:22.256081+00:00 app[api]: Deploy 5c8d0f48 by user rohitjain991100#gmail.com
2020-04-19T11:53:23.000000+00:00 app[api]: Build succeeded
2020-04-19T11:53:27.273472+00:00 app[web.1]:
2020-04-19T11:53:27.273493+00:00 app[web.1]: > node#1.0.0 start /app
2020-04-19T11:53:27.273493+00:00 app[web.1]: > node server.js
2020-04-19T11:53:27.273493+00:00 app[web.1]:
2020-04-19T11:53:27.734584+00:00 heroku[web.1]: State changed from starting to up
2020-04-19T11:53:27.649117+00:00 app[web.1]: app is running on port 30116
2020-04-19T11:53:47.570119+00:00 heroku[router]: at=info method=GET path="/" host=warm-reef-38212.herokuapp.com request_id=3624d2fe-2e3a-4e0c-99d0-3f06882d864c fwd="157.39.217.175" dyno=web.1 connect=3ms service=12ms status=304 bytes=181 protocol=https
2020-04-19T11:54:51.279964+00:00 heroku[router]: at=info method=OPTIONS path="/" host=warm-reef-38212.herokuapp.com request_id=2ee65713-56e6-45b2-ba85-8d5aac800275 fwd="157.39.217.175" dyno=web.1 connect=1ms service=3ms status=204 bytes=301 protocol=https
2020-04-19T11:59:28.292870+00:00 heroku[router]: at=info method=OPTIONS path="/register" host=warm-reef-38212.herokuapp.com request_id=ef749eda-243d-4d3f-aedd-92c995701359 fwd="157.39.217.175" dyno=web.1 connect=1ms service=2ms status=204 bytes=301 protocol=https
2020-04-19T11:59:32.895743+00:00 heroku[router]: at=info method=OPTIONS path="/signin" host=warm-reef-38212.herokuapp.com request_id=34278a55-19f1-4ee1-9eae-0d9d60e0a6bc fwd="157.39.217.175" dyno=web.1 connect=1ms service=4ms status=204 bytes=301 protocol=https
2020-04-19T11:59:33.562086+00:00 heroku[router]: at=info method=POST path="/signin" host=warm-reef-38212.herokuapp.com request_id=2087a4b7-1701-4c2c-91de-3ee3085e861d fwd="157.39.217.175" dyno=web.1 connect=1ms service=41ms status=400 bytes=267 protocol=https
2020-04-19T11:59:33.878990+00:00 heroku[router]: at=info method=POST path="/signin" host=warm-reef-38212.herokuapp.com request_id=b47adc7b-6c48-4d42-b69f-12544286a6d4 fwd="157.39.217.175" dyno=web.1 connect=0ms service=16ms status=400 bytes=267 protocol=https
2020-04-19T11:59:34.454755+00:00 heroku[router]: at=info method=POST path="/signin" host=warm-reef-38212.herokuapp.com request_id=518c21f9-5d5f-4860-b2a8-e48c84096f8e fwd="157.39.217.175" dyno=web.1 connect=0ms service=11ms status=400 bytes=267 protocol=https
2020-04-19T11:59:34.565367+00:00 heroku[router]: at=info method=POST path="/signin" host=warm-reef-38212.herokuapp.com request_id=f63998c3-7850-435c-85d2-efbbde3040ef fwd="157.39.217.175" dyno=web.1 connect=2ms service=14ms status=400 bytes=267 protocol=https
2020-04-19T11:59:34.871204+00:00 heroku[router]: at=info method=POST path="/signin" host=warm-reef-38212.herokuapp.com request_id=a2322ada-8faf-4964-b5ea-76c68bba69b7 fwd="157.39.217.175" dyno=web.1 connect=1ms service=23ms status=400 bytes=267 protocol=https
2020-04-19T11:59:34.992259+00:00 heroku[router]: at=info method=POST path="/signin" host=warm-reef-38212.herokuapp.com request_id=7e896a02-2d8f-4713-99fb-26ae2bb01a02 fwd="157.39.217.175" dyno=web.1 connect=1ms service=10ms status=400 bytes=267 protocol=https
2020-04-19T12:31:42.742729+00:00 heroku[web.1]: Idling
2020-04-19T12:31:42.746564+00:00 heroku[web.1]: State changed from up to down
2020-04-20T03:36:37.247697+00:00 heroku[web.1]: Unidling
2020-04-20T03:36:37.262797+00:00 heroku[web.1]: State changed from down to starting
2020-04-20T03:36:42.828317+00:00 app[web.1]:
2020-04-20T03:36:42.828354+00:00 app[web.1]: > node#1.0.0 start /app
2020-04-20T03:36:42.828355+00:00 app[web.1]: > node server.js
2020-04-20T03:36:42.828355+00:00 app[web.1]:
2020-04-20T03:36:43.203099+00:00 app[web.1]: app is running on port 11796
2020-04-20T03:36:43.849848+00:00 heroku[web.1]: State changed from starting to up
2020-04-20T03:36:45.324642+00:00 heroku[router]: at=info method=GET path="/" host=warm-reef-38212.herokuapp.com request_id=40c07246-2b5b-4079-bda3-04b6347c2290 fwd="157.39.3.225" dyno=web.1 connect=0ms service=13ms status=304 bytes=181 protocol=https
2020-04-20T03:36:45.998463+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=warm-reef-38212.herokuapp.com request_id=e3b41154-ef4f-4823-833f-74a8dc7b29c2 fwd="157.39.3.225" dyno=web.1 connect=0ms service=6ms status=404 bytes=426 protocol=https
2020-04-20T03:54:04.000000+00:00 app[api]: Build started by user rohitjain991100#gmail.com
2020-04-20T03:54:26.193272+00:00 app[api]: Deploy 1da13236 by user rohitjain991100#gmail.com
2020-04-20T03:54:26.193272+00:00 app[api]: Release v22 created by user rohitjain991100#gmail.com
2020-04-20T03:54:27.082771+00:00 heroku[web.1]: Restarting
2020-04-20T03:54:27.096340+00:00 heroku[web.1]: State changed from up to starting
2020-04-20T03:54:27.000000+00:00 app[api]: Build succeeded
2020-04-20T03:54:31.467317+00:00 app[web.1]:
2020-04-20T03:54:31.467339+00:00 app[web.1]: > node#1.0.0 start /app
2020-04-20T03:54:31.467340+00:00 app[web.1]: > node server.js
2020-04-20T03:54:31.467340+00:00 app[web.1]:
2020-04-20T03:54:31.978215+00:00 heroku[web.1]: State changed from starting to up
2020-04-20T03:54:31.771327+00:00 app[web.1]: app is running on port 36319
2020-04-20T03:57:17.192518+00:00 heroku[router]: at=info method=OPTIONS path="/register" host=warm-reef-38212.herokuapp.com request_id=5854e26c-7119-4abc-bdd5-b398b8f051d0 fwd="157.39.119.21" dyno=web.1 connect=1ms service=9ms status=204 bytes=301 protocol=https
2020-04-20T03:57:17.634127+00:00 heroku[router]: at=info method=OPTIONS path="/signin" host=warm-reef-38212.herokuapp.com request_id=9bbc745e-1e7f-47c6-90d9-08e1aac92589 fwd="157.39.3.225" dyno=web.1 connect=1ms service=2ms status=204 bytes=301 protocol=https
2020-04-20T03:57:19.675739+00:00 heroku[router]: at=info method=POST path="/signin" host=warm-reef-38212.herokuapp.com request_id=8108baef-41d0-4b0c-a5dc-3967fe2098e4 fwd="157.39.3.225" dyno=web.1 connect=1ms service=24ms status=400 bytes=267 protocol=https
2020-04-20T04:18:31.000000+00:00 app[api]: Build started by user rohitjain991100#gmail.com
2020-04-20T04:18:52.526320+00:00 app[api]: Deploy 1c1b07e7 by user rohitjain991100#gmail.com
2020-04-20T04:18:52.526320+00:00 app[api]: Release v23 created by user rohitjain991100#gmail.com
2020-04-20T04:18:53.554662+00:00 heroku[web.1]: Restarting
2020-04-20T04:18:53.558703+00:00 heroku[web.1]: State changed from up to starting
2020-04-20T04:18:53.000000+00:00 app[api]: Build succeeded
2020-04-20T04:18:57.947008+00:00 app[web.1]:
2020-04-20T04:18:57.947025+00:00 app[web.1]: > node#1.0.0 start /app
2020-04-20T04:18:57.947026+00:00 app[web.1]: > node server.js
2020-04-20T04:18:57.947026+00:00 app[web.1]:
2020-04-20T04:18:58.227322+00:00 app[web.1]: app is running on port 12966
2020-04-20T04:18:58.560135+00:00 heroku[web.1]: State changed from starting to up
^C
rohit#rohit-Vostro-3583:~/Desktop/smartbrainAPI$ heroku pg:info
=== DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 12.2
Created: 2020-04-19 08:42 UTC
Data Size: 8.3 MB
Tables: 2
Rows: 1/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Cont
<!-- begin snippet: js hide: false console: true babel: false -->
This is what error I am getting This is showing that i have database also for it
Help me in finding out what to change
I ahve done git add .
git commit
git push heroku master
Heroku open is also working finely
Dont know what error is
{
"name": "node",
"version": "1.0.0",
"description": "no",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"start:dev": "nodemon server.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^2.0.3"
},
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.19.0",
"clarifai": "^2.9.1",
"cors": "^2.8.5",
"express": "^4.17.1",
"knex": "^0.20.13",
"password-hash": "^1.2.2",
"pg": "^8.0.1",
"serve": "^11.3.0"
}
}
This is my package.json file

An error occurred in the application and your page could not be served.

I'm trying to deploy my app using heroku , but every time it shows me an error.
Bitbucket link of my website https://bitbucket.org/shanky_2107/cms_node_js/src/master/CMS/
If want to see the code of the app.
2018-09-04T06:27:15.431388+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-04T06:27:18.531623+00:00 app[web.1]:
2018-09-04T06:27:18.531642+00:00 app[web.1]: > cms#1.0.1 start /app
2018-09-04T06:27:18.531644+00:00 app[web.1]: > node app.js
2018-09-04T06:27:18.531646+00:00 app[web.1]:
2018-09-04T06:27:19.601937+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2018-09-04T06:27:19.601957+00:00 app[web.1]: designed for a production environment, as it will leak
2018-09-04T06:27:19.601961+00:00 app[web.1]: memory, and will not scale past a single process.
2018-09-04T06:27:20.375111+00:00 app[web.1]: at parseConnectionString (/app/node_modules/mongodb/lib/url_parser.js:176:13)
2018-09-04T06:27:20.375099+00:00 app[web.1]: Error: Username containing an unescaped at-sign
2018-09-04T06:27:20.375114+00:00 app[web.1]: at parseHandler (/app/node_modules/mongodb/lib/url_parser.js:119:14)
2018-09-04T06:27:20.375115+00:00 app[web.1]: at module.exports (/app/node_modules/mongodb/lib/url_parser.js:25:12)
2018-09-04T06:27:20.375117+00:00 app[web.1]: at connect (/app/node_modules/mongodb/lib/mongo_client.js:874:3)
2018-09-04T06:27:20.375118+00:00 app[web.1]: at connectOp (/app/node_modules/mongodb/lib/mongo_client.js:269:3)
2018-09-04T06:27:20.375120+00:00 app[web.1]: at executeOperation (/app/node_modules/mongodb/lib/utils.js:419:24)
2018-09-04T06:27:20.375122+00:00 app[web.1]: at MongoClient.connect (/app/node_modules/mongodb/lib/mongo_client.js:260:10)
2018-09-04T06:27:20.375124+00:00 app[web.1]: at Promise (/app/node_modules/mongoose/lib/connection.js:427:12)
2018-09-04T06:27:20.375126+00:00 app[web.1]: at new Promise (<anonymous>)
2018-09-04T06:27:20.375128+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:424:19)
2018-09-04T06:27:20.375129+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:207:15)
2018-09-04T06:27:20.375131+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:18:10)
2018-09-04T06:27:20.375133+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-09-04T06:27:20.375135+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-09-04T06:27:20.375136+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-09-04T06:27:20.375138+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-09-04T06:27:20.376975+00:00 app[web.1]: listening on port 21277
2018-09-04T06:27:21.091384+00:00 heroku[web.1]: State changed from starting to up
2018-09-04T06:28:13.799191+00:00 heroku[router]: at=info method=GET path="/robots.txt" host=thawing-brushlands-91259.herokuapp.com request_id=197f0f56-aba8-47ad-8f0a-d18fbb987d42 fwd="122.162.24.61" dyno=web.1 connect=1ms service=30ms status=302 bytes=342 protocol=https
2018-09-04T06:28:43.726779+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=thawing-brushlands-91259.herokuapp.com request_id=33d15316-02a5-45d7-bed7-46e6feb52f4f fwd="122.162.24.61" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
2018-09-04T06:28:44.730759+00:00 heroku[router]: at=info method=GET path="/robots.txt" host=thawing-brushlands-91259.herokuapp.com request_id=d618ac8b-1cf4-429d-90e0-a184b4002443 fwd="122.162.24.61" dyno=web.1 connect=1ms service=4ms status=302 bytes=212 protocol=https
2018-09-04T06:28:45.031657+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=thawing-brushlands-91259.herokuapp.com request_id=b258180e-8452-4a2c-a47a-37a3c1b42058 fwd="122.162.24.61" dyno=web.1 connect=0ms service=7ms status=302 bytes=212 protocol=https
2018-09-04T06:29:04.113724+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=thawing-brushlands-91259.herokuapp.com request_id=082fa342-5c79-4bb4-9bb9-fc9d84990058 fwd="122.162.24.61" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
2018-09-04T06:29:15.073424+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=thawing-brushlands-91259.herokuapp.com request_id=aa089785-742c-45c4-8fdf-4002afa634a8 fwd="122.162.24.61" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
2018-09-04T06:29:35.330371+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=thawing-brushlands-91259.herokuapp.com request_id=8976a615-8d12-47e3-8e90-0b4b40cdfcfd fwd="122.162.24.61" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
It seems that your connection string has some characters which have to be escaped. e.g. '#'. Based on the error I suppose that you have that characters in your Username. Try to use the following syntax to establish the connection to DB. It should solve the problem
mongoose.connect('mongodb://localhost/test',
{user: 'username', pass: 'p#ssword'},
callback);
read mongoose docs for more details

Resources