How fix number of connection for heroku staging DataBase - heroku

I'm using heroku to deploy my Rails 2.3.6 application.I'm using production Database backup for my staging server.But when i using this command for restart heroku.
heroku restart --app gentle-gorge-9319
after restart heroku when i reresh application home page i have this message in heroku logs
remaining connection slots are reserved for non-replication
superuser connections + heroku staging error
How i can increase connection pool for staging server.
Any help will be more appreciated...
Thanks

Related

Heroku redis/sidekiq Connection timed out - user specified timeout error

This is an issue that happened after upgrading my Redis instance version on Heroku using heroku redis:upgrade
The error happened when Sidekiq tried to connect to Redis:
Connection timed out - user specified timeout
After reading this guide:
https://github.com/mperham/sidekiq/wiki/Using-Redis#life-in-the-cloud
I thought the problem might be in the network connection, so I tried increasing the network timeout in config/initializers/sidekiq.rb like this:
config.redis = { network_timeout: 5 }
Unfortunately this did not help, it only increased the time that it takes to create the connection, but the same error was still occurring in the end.
I noticed that after upgrading the Redis instance version, Heroku had not updated the REDIS_URL config var to match the new redis url.
So, the URL in the config var:
heroku config:get REDIS_URL
was different from the one returned by:
heroku redis:credentials
So my solution was as per the following guide:
https://devcenter.heroku.com/articles/managing-heroku-redis-using-cli#redis-credentials
to reset Redis the credentials:
heroku redis:credentials --reset
With this command, new credentials are created for the Redis instance and the related config vars on the Heroku application are automatically updated.

AWS RDS: error: password authentication failed for user "ubuntu" from EC2

I have a postgres RDS instance which my Node.js web application running on an EC2 instance is not able to connect to. The error in my EC2 node logs is: error: password authentication failed for user "ubuntu"
I can confirm that I have the right username, password, database name, etc because it is working correctly on the development build on my machine. I copied all the .env parameters exactly into my ec2 machine for the production build. When attempting to connect to RDS on my production application web page, it fails. I have restarted my Node.js server multiple times and have rebooted the whole ec2 machine. I have confirmed that the env variables are there with printenv.
What would you recommend trying to fix this issue?
EDIT for more details: My nodejs setup should be correct because my nodejs server will call some external APIs that do not require my postgres database and those calls work properly.
EDIT2: This is strange because my username for RDS is postgres, while my username for EC2 is ubuntu. I wonder if somehow there's some clash between env variables. I checked printenv but didn't find any though
EDIT3: See comments for my workaround.
I would suggest to test the database credentials by directly connecting to RDS database using psql client on EC2 instance.

How to connect to Heroku postgres db from WSL2?

I have a flask app running on Heroku with postgres database.
When trying to run the app localy on WSL2, the app runs, but when there is interaction with the db it curshes with the following error:
connection to server at "x-x-x-x-169.compute-1.amazonaws.com" (x.xxx.xxx.169), port 5432 failed: FATAL: database "xxxxxx828vkthi
" does not exist
(I have replaced the numbers with x)
I have opened port 5432 on windows, but still the same error appear.
Any suggestions on how to do it?
My setup on the flask app is
app = Flask(__name__)
DATABASE_URI = os.environ['DATABASE_URL']
DATABASE_URI= DATABASE_URI[:8]+'ql' + DATABASE_URI[8:]
engine = create_engine(DATABASE_URI)
db=scoped_session(sessionmaker(bind=engine))
Nothing should prevent this from working on the Heroku side. Just make sure to always use the connection information provided by DATABASE_URL (it can change at any time) and to use sslmode=require. You can get the current value of the DATABASE_URL by running
heroku config:get DATABASE_URL
Since this is an outbound connection you shouldn't have to open any ports on WSL or Windows. Out of the box, this outbound connection should work.

Unable to connect to Heroku Postgres from Play 2.3

I have a Play 2.3 app in Java. For this app, I am able to connect to local Postgres server.
But I am unable to connect to Heroku Postgres server.
I have following settings in my application.conf:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://ec2test.amazonaws.com:5432/rwerwerwer"
db.default.user=eerwerwerer
db.default.password="5345fdwfdsvfvsdfsdfds"
I am getting following error:
Caused by: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for ho
st "172.56.17.147", user "eerwerwerer", database "rwerwerwer", SSL off
From PgAdim III, I am able to successful connect to Heroku database.
While adding heroku config, I got:
**! No app specified.**
Follow these steps.
Things to remember:
Use Heroku commands from inside your main directory.
Use database connection as:
db.default.driver=org.postgresql.Driver
db.default.url=${?DATABASE_URL}
No need for username and password.
No need for Procfile.

heroku pg:psql not working

I tried to connect to the Postgres database for my app on heroku by running the command "heroku pg:psql" and got the following error message:
psql: could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "URL.com"(IP address) and accepting
TCP/IP connections on port 5432?
I also tried to connect using Pgadmin and get the error:
Server doesn't listen. Is the server running on host "URL.com" (IP address) and accepting
TCP/IP connections on port 5432?
Can anyone tell me how to fix these errors and correctly connect to my database.
Thanks in advance!
Try this:
heroku pg:psql DATABASE_URL
As started to hint already using DATABASE_URL there are few more things to consider.
If you have multiple apps in Heroku it is always good to specify to what app you want to connect to where DB is added. Same applies if you have multiple databases to specify DB name (if it is something else than default DATABASE_URL).
Some examples how to connect:
-- Defining to what DB and app you want to connect to:
heroku pg:psql [lower case generated name] -a myapp
heroku pg:psql [lower case generated name] --app myapp
heroku pg:psql HEROKU_POSTGRESQL_[upper case generated name]_URL -a myapp
-- This will fall back to default DATABASE_URL part of your app:
heroku pg:psql -a myapp
Also to keep in mind as said here https://devcenter.heroku.com/articles/heroku-local#copy-heroku-config-vars-to-your-local-env-file:
Keep in mind that your deployed production app may be connecting to
different services than your local development app. For example, your
deployed production app might have a DATABASE_URL config var that
references a Heroku Postgres database, but your local app might have a
DATABASE_URL variable in the .env file that references your local
installation of Postgres.
Heroku guideline – https://devcenter.heroku.com/articles/heroku-postgresql#pg-psql (but it explains little about multi-database and multi-apps cases).
Heroku guideline for connecting externally - https://devcenter.heroku.com/articles/connecting-to-heroku-postgres-databases-from-outside-of-heroku
This answer might be silly, but it happened to me before. The internet connection I was in is blocking the connection on that port.

Resources