Reputation: 139
I'm using Heroku's Postgres add-on in one of my NodeJS apps. The code seems to work but any connections to the database using this module hangs and never responds with neither a success or a failure.
To investigate the issue, I tried connecting to the database through my terminal using pgcli <db url>
but got the following error:
could not send SSL negotiation packet: Resource temporarily unavailable
.
Further details:
Any help would be appreciated.
Upvotes: 0
Views: 3152
Reputation: 4057
.env
DATABASE_URL=verylongstring
index.js
require('dotenv').config()
const pg = require('pg'
const pgPool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
})
If your using github or some other service to store your code make sure to not send the .env file with you since its only for local development. Heroku has the environmental variables in your app.
.gitignore
.env
Upvotes: 1