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"
}
}