We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I created a .pgpass file in the user's home directory:
vi ~/.pgpass\
I added the connection details:
182.10.203.23:5432:database:username:verystrongpass\
I then tested the connection using psql and it successfully connects to the database using the credentials from the file:
psql
Next, I prepared the development environment:
Created a .env file to set up the environment: NODE_ENV=development PGPASSFILE=/home/username/.pgpass
Installed the postgres npm package:
npm install postgres
import postgres from 'postgres' const sql = postgres() const data = await sqlselect * from mytable console.log(data)
select * from mytable
4 Ran the script
node --env-file=.env test.mjs
I got the following error:
Error: connect ECONNREFUSED 127.0.0.1:5432
This indicates that it is trying to connect using the default localhost:5432 connection and not using the configuration from .pgpass.
How can I configure the connection to read from PGPASSFILE?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I created a .pgpass file in the user's home directory:
I added the connection details:
I then tested the connection using psql and it successfully connects to the database using the credentials from the file:
Next, I prepared the development environment:
Created a .env file to set up the environment:
NODE_ENV=development
PGPASSFILE=/home/username/.pgpass
Installed the postgres npm package:
4 Ran the script
I got the following error:
This indicates that it is trying to connect using the default localhost:5432 connection and not using the configuration from .pgpass.
How can I configure the connection to read from PGPASSFILE?
The text was updated successfully, but these errors were encountered: