When I try to run my app on http://localhost:3000 I get following error
FATAL: password authentication failed for user "postgresq".
Not sure what is the issue, because in database.yml file my password is correct:
default: &default
adapter: postgresql
database: Dzeus
encoding: unicode
username: postgresq
password: mypassword
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
I'm able to connect to the database via pg admin program using the same password. Yesterday it worked fine but today something changed and I'm getting this error. Could you please help?
Related
I am trying to deploy ruby app to aws using elastic beanstalk. I cd into repo, then git init, git add --all, git commit -am "update", eb init, eb create staging3 -db.engine postgres, fixed some error, then eb deploy. Now I get
FATAL: password authentication failed for user "ebroot"
My database.yml
adapter: postgresql
host: localhost
username: ggg
database: rtt
production:
adapter: postgresql
encoding: utf8
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
My log http://pasted.co/6590f3ae
I am noob, Is this password has any connection with the password I created when database creation and migration locally.
Changing password: <%= ENV['RDS_PASSWORD'] %> to password: "<%= ENV['RDS_PASSWORD'] %>" fixes the problem. Can you please tell me why this is like this?
Can a sails.js database connection be configured using a URI, or a URL which incorporates the credentials (host, user, password, and database) into one string? Or do they need to be individually assigned as their own key-value pairs in the configuration?
In development, I have configured my sails.js app to use environment variables for database credentials, as such:
in connections.js:
someSqlDatabase: {
host: process.env.dbHost,
user: process.env.dbUserName,
password: process.env.dbPassword,
database: process.env.db,
port: 5432,
ssl: true,
adapter: 'sails-postgresql'
This works for my connection to a heroku-postgresql resource that I've allocated to my project, and I am able to manually set "Config Vars" in my heroku instance, which I can use in the same way as environment variables in my local instance. By this I mean I can go to the heroku client page for the database resource, copy its credentials (host, database, user, and password) into the heroku app's configuration variables, individually.
The problem is that heroku periodically changes the credentials, and that my manually-copied configuration variables will become outdated, and require re-pasting whenever this happens. Obviously, this is not an ideal solution.
Heroku does automatically provide one configuration variable for the resource, called DATABASE_URL, which looks like:
"postgres://<user>:<password>#<host>:<port>/<database>"
which should be automatically updated, when the credentials change.
My problem is that I don't know how to configure a sails.js connection to use this url, in the place of individual "host", "user", "password", and "database" key/value pairs in the the connection config.
I've tried using a configuration that omits the individual keys and uses only "host", as such:
someSqlDatabase: {
host: process.env.DATABASE_URL,
ssl: true,
adapter: 'sails-postgresql'
}
But this connection fails. I've seen this kind of string called a URI, and I've tried the long-shot configuration:
someSqlDatabase: {
uri: proccess.env.DATABASE_URL
ssl: true,
adapter: 'sails-postgresql'
}
but this fails, as well. Is there a way to configure a sails-js connection with heroku postgresql database that will automatically use the latest credentials? (I am using sails v0.12.3)
I am not using PostgreSQL, but you could try/adapt this:
// before/outside module.exports
var url = require('url').parse(process.env.DATABASE_URL);
// within the config
someSqlDatabase: {
host: url.host,
user: url.auth.split(':')[0],
password: url.auth.split(':')[1],
database: url.pathname.substring(1),
port: url.port,
ssl: true,
adapter: 'sails-postgresql'
}
The following is probably the correct way to do this :
module.exports = {
...
default: {
ssl: true,
url: process.env.HEROKU_POSTGRESQL_SILVER_URL,
adapter: 'sails-postgresql'
},
...
}
inside config/env/production.js
I'm building an application in MeteorJS.
I want to have GUI access to built-in MongoDB database.
So I found: https://github.com/andzdroid/mongo-express
I installed it, configured it to connect to localhost:3001.
Since mongodb doesn't have a default admin password, I tried to create it by:
meteor mongo
use admin
db.addUser("admin","password")
then I set
adminUsername: 'admin',
adminPassword: 'password',
in mongo-express\config.js.
However when I open localhost:8081, it asks me login credentials again and even if I insert them manaully (admin, password) it doesn't work.
So I went back to meteor mongo, tried to create admin user again and go error
Error: couln't add user: User admin#admin" already exists
What am I doing wrong?
edit /usr/local/lib/node_modules/mongo-express/config.default.js
find and edit to:
} else {
mongo = {
db: 'meteor',
host: 'localhost',
password: '',
port: 3001,
ssl: false,
url: 'mongodb://localhost:3001/meteor',
username: '',
};
}
I'm currently working on a project where I use mongodb as database, and I began with no security in my mongo configuration of the symfony config.yml.
This is what my config.yml looked like since the beginning of the project.
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: louisv
document_managers:
default:
auto_mapping: true
With this parameters the project works very well.
But I want to add security to mongodb database. So I tried to follow documentation on mongodb to create users. I created an "admin" user for the admin database, and a "louisv" user for the louisv database (the admin database is the database existing by default, and louisv is mine).
Now I want to Symfony to use this new user. I changed my the option parameters from my conf.yml file and now this is what I have :
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options:
username: louisv
password: password
default_database: louisv
document_managers:
default:
auto_mapping: true
Now when I try to enter my application in Symfony
Failed to connect to: localhost:27017: Authentication failed on database 'admin' with username 'louisv': auth fails
Which is weird cause my default_database is "louisv' and not 'admin'.
And if I change the credentials to admin's ones, I have another error:
localhost:27017: not authorized for query on louisv.User
Which seems quite good as it seems to search for users, but I can't do queries.
Instead of:
server: mongodb://localhost:27017
The following should do the trick:
server: mongodb://localhost:27017/louisv
Apparently, the Doctrine ODM bundle also has a "db" option now, so you now have the following options:
connections:
default:
server: mongodb://louisv:password#localhost:27017/louisv
or
connections:
default:
server: mongodb://localhost:27017
options:
username: louisv
password: password
db: louisv
The first option is preferred, as it allows for automatic re-authentication in case a connection drops.
See also:
https://github.com/doctrine/DoctrineMongoDBBundle/issues/154
In addition to #derick's answer, my configuration was still trying to connect to the "default" database - adding the default_database entry solved this.
connections:
default:
server: "mongodb://myuser:password#mydbserver:27017/mydb"
default_database: mydb
Remember to keep usernames and passwords in a "parameters" file separate from the config file if stored in source control :)
I just deployed the rails app with Rubber on EC2.Additionally a RDS instance is created for the database. Run
$ cat /etc/host
to get the rubber config on production as
But when I browse http://web01.musemebackend.com/admin/login, I got the error of '504 Gateway Time-out, server didn't respond in time'
The error log in apache2 shows:
[ pid=1813 thr=12161140 file=utils.rb:176 time=2013-03-06 20:49:28.175 ]:
*** Exception PhusionPassenger::UnknownError in PhusionPassenger::Rack::ApplicationSpawner (Can't connect to MySQL server on 'musemedb.cfmz4gvshyts.us-east-1.rds.amazonaws.com' (110) (Mysql2::Error)) (process 1813, thread #<Thread:0x000000017320e8>):
As I modified the config/database.yml:
production:
adapter: mysql2
encoding: utf8
database: muse_me_backend_production
username: app_admin
password: MYPASSWORD
host: musemedb.cfmz4gvshyts.us-east-1.rds.amazonaws.com
port: 3306
modified config/rubber/rubber-mysql.yml as:
# REQUIRED: The credentials for creating/accessong your app's database
#
db_user: app_admin
db_pass: MYPASSWORD
db_name: muse_me_backend_production
db_host: musemedb.cfmz4gvshyts.us-east-1.rds.amazonaws.com
and config/rubber/common/database.yml as
<%
#path = "#{Rubber.root}/config/database.yml"
%>
<%= Rubber.env %>:
adapter: <%= YAML::load(File.open("#{Rubber.root}/config/database.yml"))["production"]["adapter"] %>
encoding: utf8
database: <%= rubber_env.db_name %>
username: <%= rubber_env.db_user %>
password: <%= rubber_env.db_pass %>
host: <%= rubber_env.db_host %>
pool: 5
The app should be deployed successfully. Database migrations are raked successfully too. Are there anything I missed to connect the server? Do I need to own the domain name of musemebackend.com? Now I don't own it. I saw in tutorial it was just foo.com. Does that matter?
Thanks
The problem was that I didn't add the security group of the app role instance to DB security group. Now it was fixed.