FATAL: password authentication failed for user "postgres", after "docker-compose up -d" on your EC2 AMI


#1

Issue Summary

Today we setup EC2 instance according to https://redash.io/help/open-source/setup#aws .

After setup, redash worked perfectly.

But we execute sudo -E docker-compose up -d command, then Internal Server Error always occurs. (No fix in /opt/redash/env file.)

According to sudo -E docker-compose logs result of this command, the following error occurred.

OperationalError: (psycopg2.OperationalError) FATAL:  password authentication failed for user "postgres"

What is the reason for this error?


AMI image: postgres password auth failure
#2

Seems like your containers started with the wrong configuration. Try stopping all the containers and run the compose command from /opt/redash.


#3

Thank you for your reply. After new instance is created,

cd /opt/redash
sudo docker-compose up -d

It is still Internal Server Error. AMIs version 5.0.1 are having some problems?


#4

sudo docker-compose down
sudo docker-compose up -d

I tried it like this, but it did not solve it.


#5

I have exactly same issue


#6

Do you still see the same error in the logs?


#7

I just posted about the exact same issue.


#8

Yes.

server_1            |   File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in connect
server_1            |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
server_1            | OperationalError: (psycopg2.OperationalError) FATAL:  password authentication failed for user "postgres"
server_1            |  (Background on this error at: http://sqlalche.me/e/e3q8)
server_1            | [2018-10-11 01:59:54,183][PID:14][INFO][metrics] method=GET path=/login endpoint=redash_login status=500 content_type=? content_length=-1 duration=13.08 query_count=0 query_duration=0.00

#9

Check the content of /opt/redash/env: is the password set in POSTGRES_PASSWORD same as the one in REDASH_DATABASE_URL?


#10

Got the AMI and trying to set up to play around.

Was following these instructions, updated the configs, and tried to re-start docker. When re-accessing the app from the browser, I get the following message.

Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

On the server logs, I see

scheduler_1 | OperationalError: (psycopg2.OperationalError) FATAL: password authentication failed for user “postgres”

Anybody know what’s up?


#11

The password is a default password written on /opt/redash/env (not editted.)

If you do yourself on EC2 using provided AMI by redash, the problem will be reproduced.


Environment variables ignored (√ SOLVED)
#12

I managed to reproduce this. The issue is the following: when the Postgres container is run for the first time it creates its configuration and after that point you can no longer change the postgres user password.

When the instance boots we update the COOKIE SECRET and Postgres password to new values, so that not all the instances share the same ones. But for Postgres this has no effect.

To fix this, update your /opt/redash/env files to includes the following values:

POSTGRES_PASSWORD=26aeSTZnG2NpumVfD8AyWXtqaggmuOrJ
REDASH_DATABASE_URL=postgresql://postgres:26aeSTZnG2NpumVfD8AyWXtqaggmuOrJ@postgres/postgres

As an alternative, you can login to Postgres with the above password and update the password of the postgres user to use the new one that was generated by your instance. This is actually more secure.

We will create new AMIs now to avoid this issue for future users.


How to set REDASH_MULTI_ORG in AWS AMI?
#13

I solved this problem completely according to the solution, thank you!


#14

@arikfr

I have the very same issue, however, the POSTGRES_PASSWORD you gave does not work for me.

I am using the redash-5-0-1 gcloud image from the example at https://redash.io/help/open-source/setup#-google-compute-engine