I had the same issue for setting up my local environment after the tutorial. Sticking to the command heroku local
to start my server fixed it for me. This command is detailed in the Run the app locally section of the tutorial.
In my case I added a Express server and a client side using React + Webpack. My package.json
scripts for local development look like:
"dev": "run-p dev:*",
"dev:server": "heroku local -f Procfile.dev",
"dev:webpack": "webpack --watch --config webpack.dev.js --mode development",
run-p
is just from npm-run-all
to run all scripts starting with dev
at the same time.
- The server uses the
heroku local
command and a specific Procfile
for local development (use -f
flag to do this), where I start a server locally with nodemon
to watch for changes (see the Procfile.dev
below).
- The webpack script builds and watches for changes on the client side with React.
Procfile.dev
for local development:
web: nodemon index.js
Procfile
for production:
web: node --optimize_for_size --max_old_space_size=920 --gc_interval=100 index.js
Then the same code for connecting to the DB from the Provision a database section works for me:
const { Pool } = require('pg');
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
});
ssl = on
inpostgresql.conf
, provide server certificates and restart the server?