I am seeing the following error on my Linode server (Ubuntu 17.04) when starting up my Rails app:
PG::ConnectionBad: FATAL: password authentication failed for user "postgres"
The odd thing is that this is only happening on my remote server. Locally (on my Mac), it's working fine. I have the following docker-compose.yml file:
version: "2"
services:
postgres:
image: postgres:9.6
ports:
- "5432:5432"
environment:
POSTGRES_DB: "${DATABASE_NAME}"
POSTGRES_PASSWORD: "${DATABASE_PASSWORD}"
volumes:
- postgres-data:/var/lib/postgresql/data
redis:
image: redis:latest
ports:
- "6379:6379"
volumes:
postgres-data:
driver: local
which should bind Postgres to port 5432 on localhost and set the password to the DATABASE_PASSWORD environment variable. If I run ps aux | grep 5432
on the server I can see the Docker process is running correctly:
root 29550 0.0 0.2 34472 2888 ? Sl 01:34 0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5432 -container-ip 172.18.0.3 -container-port 5432
So I cannot figure out why I'm getting a password authentication failed error message.
My config/database.yml file:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: localhost
username: postgres
...
production:
<<: *default
database: <%= ENV['DATABASE_NAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
The variables are set in my environment and I am able to echo them properly from the shell.
Any help would be much appreciated! Thanks
After much head-bashing I solved the problem. Not sure exactly how but the following seemed to work:
Installed ntp just to make sure time settings were ok
$ sudo timedatectl set-ntp no
$ sudo apt-get install ntp
$ sudo ntpq -p
specified a Redis image version
redis:
image: redis:4.0
ports:
- "6379:6379"
then tried destroying all the Docker images
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -qf dangling=true)
and finally tried to restart Docker
docker-compose up -d
Seems to be working as intended now.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments