I have configured by database.yml file according to this guide but it always comes back the error:
Error in Compute Engine
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/cloudsql/[YOUR_INSTANCE_CONNECTION_NAME]/.s.PGSQL.5432"?
I have whitelisted the network of 0.0.0.0/0 and also tried this guide where you install the cloud sql proxy, but still no luck.
database.yml
production:
adapter: postgresql
encoding: unicode
pool: 5
timeout: 5000
database: databse-name
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
database: <%= ENV['DATABASE'] %>
host: <%= ENV['DATABASE_HOST'] %>
sslca: config/ssl/server-ca.pem
sslcert: config/ssl/client-cert.pem
sslkey: config/ssl/client-key.pem
Related
I created an postgres RDS instance,** which I can connect to from my EC2 instance and my local shell**.
But for some reason when I run rails db:create I get the following error:
FATAL: password authentication failed for user "my_user"
Any pointers?
I can connect to the RDS instance from EC2 instance and local machine.
I expect rails to be able to run migrations as well, but it throws an error.
db.yml:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: use
password: gresgres
development:
<<: *default
database: myapp_dev
test:
<<: *default
database: myapp_test
production:
<<: *default
database: <%= ENV['PG_RDS_DBNAME'] %>
username: <%= ENV['PG_RDS_USERNAME'] %>
password: <%= ENV['PG_RDS_PASSWORD'] %>
host: <%= ENV['PG_RDS_ENDPOINT'] %>
port: <%= ENV['PG_RDS_PORT'] %>
When start puma on my ec2 machine, I get this error: bad URI(is not URI?): <%= ENV['DATABASE_URL'] %> (URI::InvalidURIError) because of the database.yml I don't know why when I replace the embedded ruby code of the url with the real url the app works fine.
My database.yml:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
port: 5432
development:
<<: *default
database: <%= ENV['DATABASE_NAME'] %>
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
I use dotenv gem and I load the environment variables from another file out of my project directory.
Also, know that when I open the rails console on my ec2 machine I can connect to the database without any problem.
Can anyone help me with this problem?
I have find the answer in another stackoverflow question. Tproblem was that the database.yml was not accepting erb. So, I tried to do like the answer of the previous question and it worked fine
I'm trying to deploy my Rails 5 application using Postgres to a VPS via Capistrano. It keeps failing, though - giving me a PG::ConnectionBad: FATAL: password authentication failed for user 'sys_user'.
The relevant settings of my database.yml are:
production:
<<: *default
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
All these environment variables have been set in /etc/environment - this is definitely the case because it's picking up the RDS_USERNAME as sys_user. The password of the database is the same as the variable RDS_PASSWORD. The port, hostname etc. are all the same also.
I'm stumped. Please help.
Where is the Postgres instance running? I'm guessing that you're trying to migrate an application from Elastic Beanstalk to a non-Amazon host. If that's the case, and your Postgres instance is not actually RDS, you might need to enable password authentication in your config file.
Documentation on Postgres configuration can be found here; I suspect you might need to change ident to md5.
I have existing rails project with PostgreSQL DB. When I am running the same in my local machine I am receiving SQLite exception.
But my database.yml configured with postgres adapter only.
Here is the exception:
SQLite3::CantOpenException: unable to open database file
database.yml
postgres: &postgres
adapter: postgresql
encoding: unicode
host: localhost
pool: 5
username: postgres
password: postgres
min_messages: warning
development:
<<: *postgres
database: dev_development
username: <%= ENV['PG_USER'] || 'postgres' %>
password: <%= ENV['PG_PASSWORD'] || 'postgres' %>
test:
<<: *postgres
database: dev_test
username: <%= ENV['PG_USER'] || 'postgres' %>
password: <%= ENV['PG_PASSWORD'] %>
Perhaps you have an environment variable set (DATABASE_URL) that is overriding your database.yml file? Look at this for more info: http://edgeguides.rubyonrails.org/configuring.html#configuring-a-database
If that's not it, is it possible you recently changed your database.yml file and haven't restarted the server?
Not able to connect to RDS PostgreSQL 9.3 database from EC2 (elastic-beanstalk). Environment was created using the Elastic Beanstalk v3 CLI with PostgreSQL 9.3.5, Puma (Ruby 2.1), Rails 4.1.6. postgresql93-devel was successfully installed by yum through .ebextensions/postgres.config:
packages:
yum:
postgresql93-devel: []
SECRET_KEY_BASE has been added to Environment table through console.
Getting the following error on rake db:migrate during eb deploy:
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
RDS_HOSTNAME, RDS_DATABSE, RDS_USER_NAME, RDS_PASSWORD: all verified in rails console by ssh'ing to ec2 box.
config/database.yml:
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
production:
<<: *default
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
hostname: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
Any thoughts?
It seems you have mistakenly written hostname instead of host in database.yml