Question

Can't start Postgres . password='nil' message

I am using a droplet with ubuntu/postgres/rails. I can’t seem to get the postgres server running.

I used the tutorial at https://www.digitalocean.com/community/tutorials/how-to-use-the-ruby-on-rails-one-click-application-on-digitalocean#configuration-details and have things almost running except that the postgres server won’t start. I checked with a port scanner and the port is closed

I am getting a message of

Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "host"=>"localhost", "username"=>"rails", "password"=>nil, "database"=>"christopherg_production"}
rails@ruby-rails-postgres-nginx-unicorn-512mb-nyc1-01:~/christopherg$ postgres -D /usr/local/pgsql/data
postgres: Postgres-XC: must start as either a Coordinator (--coordinator) or Datanode (--datanode)
rails@ruby-rails-postgres-nginx-unicorn-512mb-nyc1-01:~/christopherg$ pg_ctl start -l logfile
pg_ctl: Coordinator or Datanode option not specified (-Z)
Try "pg_ctl --help" for more information.

I tried starting it with pg_ctl start -l logfile postgres -D /usr/local/pgsql/data

and a couple of other variations.

I’d appreciate any thoughts as to how to get postgres running

Does “password”=>nil, mean that postgres is not picking up the environment variable?

Subscribe
Share

@cgmendla - I believe that one-click app usually has the postgres server set up once the droplet boots? To test this, try the command: pg_ctl status

@cgmendla - Use the pg_config command to look for the location of the configuration file. Most likely, the conf file is somewhere in /etc/postgres*

Edit: my PGDATA was in /var/lib/postgresql/data

It looks like it isn’t picking up the environment variables


pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
rails@ruby-rails-postgres-nginx-unicorn-512mb

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@cgmendla - The username (usually ‘rails’) and password should show up when you log in to the one-click droplet, i.e., in the message-of-the-day. Make sure you set this password in one of your source files. Edit: the example in the tutorial uses the environment variable APP_DATABASE_PASSWORD which you can set either in your login shell’s “rc” file, or explicitly set in your script or invocation command line.