Deployment to AWS - pm2 and authentication errors

System Information
  • Strapi Version: 3.2.5
  • Operating System: MacOS
  • Database: PostrgreSQL
  • Node Version: v12.18.3
  • NPM Version: 6.14.6
  • Yarn Version: v1.13.0

Hello! Running into errors, searched high and low in forum, github issues, google… can’t find an answer. Would really appreciate any insight!

Followed this https://strapi.io/documentation/v3.x/deployment/amazon-aws.html

I changed the user password with psql. I rebooted the terminal before running npm start develop

This project was running locally just fine until I started this deployment process and now when I run the project I get this error:

  npm start develop

> strapi@0.1.0 start /Users/tina/Development/strapi
> strapi start "develop"

[2020-11-12T18:14:48.649Z] debug ⛔️ Server wasn't able to start properly.
[2020-11-12T18:14:48.650Z] error error: password authentication failed for user "postgres"
    at Parser.parseErrorMessage (/Users/tina/Development/strapi/node_modules/pg-protocol/dist/parser.js:278:15)
    at Parser.handlePacket (/Users/tina/Development/strapi/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/Users/tina/Development/strapi/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/Users/tina/Development/strapi/node_modules/pg-protocol/dist/index.js:10:42)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
From previous event:
    at Client_PG.acquireRawConnection (/Users/tina/Development/strapi/node_modules/knex/lib/dialects/postgres/index.js:108:12)
    at create (/Users/tina/Development/strapi/node_modules/knex/lib/client.js:258:21)
    at /Users/tina/Development/strapi/node_modules/tarn/lib/Pool.js:389:34
    at Object.tryPromise (/Users/tina/Development/strapi/node_modules/tarn/lib/utils.js:53:24)
    at /Users/tina/Development/strapi/node_modules/tarn/lib/Pool.js:389:17
    at new Promise (<anonymous>)
    at callbackOrPromise (/Users/tina/Development/strapi/node_modules/tarn/lib/Pool.js:380:12)
    at Pool._create (/Users/tina/Development/strapi/node_modules/tarn/lib/Pool.js:290:9)
    at Pool._doCreate (/Users/tina/Development/strapi/node_modules/tarn/lib/Pool.js:260:36)
    at Pool._tryAcquireOrCreate (/Users/tina/Development/strapi/node_modules/tarn/lib/Pool.js:211:18)
    at Pool.acquire (/Users/tina/Development/strapi/node_modules/tarn/lib/Pool.js:117:14)
    at /Users/tina/Development/strapi/node_modules/knex/lib/client.js:312:43
From previous event:
    at Client_PG.acquireConnection (/Users/tina/Development/strapi/node_modules/knex/lib/client.js:312:26)
    at Runner.ensureConnection (/Users/tina/Development/strapi/node_modules/knex/lib/runner.js:246:8)
    at Runner.run (/Users/tina/Development/strapi/node_modules/knex/lib/runner.js:25:27)
    at SchemaBuilder.Target.then (/Users/tina/Development/strapi/node_modules/knex/lib/interface.js:14:43)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! strapi@0.1.0 start: `strapi start "develop"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the strapi@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tina/.npm/_logs/2020-11-12T18_14_48_669Z-debug.log

In terminal, can log in and it looks like it connects? Status says online. But when I check logs it is basically same error as when I try to npm run develop in project:

1| | npm ERR! Failed at the strapi@0.1.0 start script.
1| | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
1| | 
1| | npm ERR! A complete log of this run can be found in:
1| | npm ERR!     /home/ubuntu/.npm/_logs/2020-11-12T18_26_31_650Z-debug.log
1| | npm ERR! code ELIFECYCLE
1| | npm ERR! errno 1
1| | npm ERR! strapi@0.1.0 start: `strapi start`
1| | npm ERR! Exit status 1
1| | npm ERR! 
1| | npm ERR! Failed at the strapi@0.1.0 start script.
1| | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
1| | 
1| | npm ERR! A complete log of this run can be found in:
1| | npm ERR!     /home/ubuntu/.npm/_logs/2020-11-12T18_26_47_230Z-debug.log

/home/ubuntu/.pm2/logs/strapi-out.log last 15 lines:
1| | [2020-11-12T18:26:47.105Z] debug ⛔️ Server wasn't able to start properly.
1| | [2020-11-12T18:26:47.123Z] error error: password authentication failed for user "postgres"
1| |     at Parser.parseErrorMessage (/home/ubuntu/strapi/node_modules/pg-protocol/dist/parser.js:278:15)
1| |     at Parser.handlePacket (/home/ubuntu/strapi/node_modules/pg-protocol/dist/parser.js:126:29)
1| |     at Parser.parse (/home/ubuntu/strapi/node_modules/pg-protocol/dist/parser.js:39:38)
1| |     at Socket.<anonymous> (/home/ubuntu/strapi/node_modules/pg-protocol/dist/index.js:10:42)
1| |     at Socket.emit (events.js:314:20)
1| |     at addChunk (_stream_readable.js:298:12)
1| |     at readableAddChunk (_stream_readable.js:273:9)
1| |     at Socket.Readable.push (_stream_readable.js:214:10)
1| |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
1| | 
1| | > strapi@0.1.0 start /home/ubuntu/strapi
1| | > strapi start
1| |

Where are you declaring the database connection information in Strapi?

If you are using the ecosystem file for PM2 we have noticed issues with PM2 lazily injecting these environment variables too late for Strapi (we recommend using the .env for environment variables and not the ecosystem)

Hi sorry! I tried and struggled to edit my post to say it was solved. But anyhow, I solved it! Thanks for the response. (Next time I’ll just respond to my original post)

1 Like

please let us know the solution. I also stuck with the issue for whole day.