trying to host my website. on aws using ec2 and rds

0

my front end is react and my backend is node/express database is postgres.

I can view my website by going to the ip address however I have troubles when trying to start the server / backend.

app is listening on 8001 /home/ec2-user/myApp/server/node_modules/pg-protocol/dist/parser.js:287 const message = name === 'notice' ? new messages_1.NoticeMessage(length, messageValue) : new messages_1.DatabaseError(messageValue, length, name); ^

error: no pg_hba.conf entry for host "my-ip-address", user "postgres", database "my-database", no encryption at Parser.parseErrorMessage (/home/ec2-user/myApp/server/node_modules/pg-protocol/dist/parser.js:287:98) at Parser.handlePacket (/home/ec2-user/myApp/server/node_modules/pg-protocol/dist/parser.js:126:29) at Parser.parse (/home/ec2-user/myApp/server/node_modules/pg-protocol/dist/parser.js:39:38) at Socket.<anonymous> (/home/ec2-user/myApp/server/node_modules/pg-protocol/dist/index.js:11:42) at Socket.emit (node:events:513:28) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23) { length: 159, severity: 'FATAL', code: '28000', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'auth.c', line: '543', routine: 'ClientAuthentication' }

Node.js v18.12.1

I have been trying to edit my pg_hba.conf file however whenever I try to edit it, it says

"/rdsdbdata/config/pg_hba.conf" [New DIRECTORY]

when I run psql SHOW hba_file; it gives me that path.

Ty
gefragt vor 9 Monaten8293 Aufrufe
2 Antworten
1
Akzeptierte Antwort

"FATAL: no pg_hba.conf entry for host" errors indicate that there was a failed authentication attempt to the database, so the connection couldn't be established. This can happen because of different reasons:

  • The authentication failed because the user/password credentials were invalid: ((user "xxxx", database "yyyy")). This could happen if you're trying to connect to the database using wrong or revoked credentials.

  • The authentication failed because the connection didn't use SSL encryption: (SSL off). If your client is not using SSL to connect to your database, you would see these errors even if you're using the right credentials to connect to it.

  • The authentication failed because the client environment had previously been configured for certificate-based Postgres authentication (mTLS) but the current server is not configured for certificate-based authentication. Look for a .postgresql subdirectory in your current user HOME directory and remove or rename any postgresql.crt subdirectory in there.

Try sudo find / -type f -name pg_hba.conf

profile picture
EXPERTE
beantwortet vor 9 Monaten
profile pictureAWS
EXPERTE
überprüft vor 9 Monaten
profile picture
EXPERTE
überprüft vor 9 Monaten
profile pictureAWS
EXPERTE
überprüft vor 9 Monaten
  • thank you. I had to add ssl=true.

    I am now getting a new error

    node:internal/process/promises:288 triggerUncaughtException(err, true /* fromPromise */); ^

    Error: connect ECONNREFUSED 127.0.0.1:5432 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16) { errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 5432 }

  • If you perform a netstat -an can you see postgress listening on the loopback address?

0

Hi there, I have the same problem, but my backend application is in NestJS and dockerized. I have NO problem accessing Postgres RDS from EC2, however, I kept having an error of "FATAL: no pg_hba.conf entry for host, no encryption" in docker shell.

I already have tried the way to fix that you commented above, I guess pg_hba.conf file is not dockerized with backend app?

PLEASE help me out as I couldn't process my project for three days now...

haccoon
beantwortet vor 6 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen