Cannot connect via heroku pg:psql (no response) [Windows] - heroku-postgres

In GitBash:
$ heroku pg:psql
--> Connecting to postgresql-rectangular-74530
And no response is given... it's just kept there
If I type, for example:
$ heroku pg:psql
That works great. (I've already set my HEROKU_APP enviroment variable, that's why I'm not passing it as a parameter.)
If I only type psql, like this:
$ psql
psql: FATAL: role "MyPCUsername" does not exist
An error is thrown... I don't if it has something to do.
I'm on Windows 7 64bits.
Any suggestion?

Run heroku pg:psql in windows command prompt, for some reason not all heroku commands work properly in git bash

Only "solution" I have is to access with pgAdmin as proposed here
Or install Ubuntu at Virtual Box and accessing via heroku pg:psql. Works like a charm in Linux

Related

When trying to access my app locally, I am given: "could not translate host name ... to address" and "Temporary failure in name resolution"

I am going through Heroku's getting started tutorial. As far as I know, Postgres is fully updated and everything is installed appropriately. Interestingly, the app works online when I deploy it to heroku, but when I try to run the app locally, not so much! I am getting a:
PG::ConnectionBad
could not translate host name "myname" to address: Temporary failure in name resolution
### Convenience alias for PG::Connection.new.
def self::connect( *args )
return PG::Connection.new( *args )
end
I have not touched any information in the files created by Heroku for this tutorial - so what could be wrong?
The following commands were run:
heroku login
git clone https://github.com/heroku/ruby-getting-started.git
cd ruby-getting-started
heroku create
git push heroku main
heroku open (this gets to the app okay) heroku logs --tail
which psql
bundle install
export DATABASE_URL=postgres://$(whoami) bundle exec rake db:create db:migrate (Here is where the error is)
heroku local web
(Error here) http://localhost:5000/
Debug Postgres connection
Confirm that Postgres exists in yout local machine, is running and it have a user that maches with you machine username.
Try to run this command in your local machine:
psql -U $(whoami) -d postgres
The output should be something like this:
psql (9.2.24, server 10.14)
WARNING: psql version 9.2, server version 10.0.
Some psql features might not work.
Type "help" for help.
postgres=#
Then, confirm that a database matching with your username exists with "\l".
postgres=#\l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------+----------+----------+-------------+-------------+-----------------------
myuser | odoo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
tip: you can close with "\q"
postgres=#\q
if no error, try replacing the value of DATABASE_URL with one of the following...
postgresql://
postgresql://localhost
postgresql://localhost:5433
postgresql://localhost/mydb
postgresql://user#localhost
If this is not successful, then you must review the way that postgres is installed.
...Or manually create a superadmin User with a password inside Postgres.
The conection string pattern is
postgres://user:password#host:port
example...
export DATABASE_URL=postgres://db_user:123456#localhost:5432
DATABASE_URL=postgres://$(whoami)
This is trying to connect to a computer which happens to have the same name as your local user account. Unsurprisingly, it doesn't exist, hence the error.
Here's the command to use if you are trying to make a backup or create a dump file from your local Postgres DB.
Mainly you need to change --host to --port, and that's it:
pg_dump --format t --no-owner --no-privileges --verbose --username postgres --password --dbname <DATABASE_NAME> --port <PORT, usually 5432> --file <THE FILE NAME YOU WANT>.dump
*if you are on Windows, use CMD instead of git bash. idk why.

Error accessing Heroku Logs from Nitrous.io

I am trying to access the log from a small Rails app that I have deployed to Heroku, from Nitrous.io.
When I run 'heroku logs' I get the following:
Unable to connect to api.heroku.com
I am guessing that I don't have something setup correctly, but have no idea what.
Can someone point me in the right direction?
Thanks,
Jim
Assuming you've already run heroku login, Try adding your Nitrous project's SSH keys to heroku. When you're in the Web IDE in your project, type in the command line:
$ heroku keys:add
Then try running heroku logs again.

script to download heroku postgres DB dump to local server

I would like to create a script that would make a dump of a postgresql DB on heroku and download it to my local server.
I using windows server 2008 R2 and would assume that this would be activated with scheduler.
On the local server installed is ruby 1.93 and chocolately (run curl on a PC).
I am assuming that the script would be a ruby file and have the commands to both create a backup and and then use a curl command to download it. The latest backup would be the only one downloaded
The commands would be something like
heroku pgbackups:capture --expire -a appname
curl -o latest.dump heroku pgbackups:url
thanks in advance
The easiest way would be to get curl for your Windows machine at http://curl.haxx.se

Heroku db:pull 'db:pull is not a heroku command'

I'm getting this message even though I've used heroku db:pull a million times. For some reason it's no longer working even though I haven't even touched my code. Any ideas?
The full error message is
db:pull is not a heroku command.
Perhaps you meant pg:pull
See heroku help for a list of available commands.
For now, we can still use heroku-legacy-taps until the taps gods decide to deprovision the taps servers.
Run: heroku plugins:install https://github.com/heroku/heroku-legacy-taps.git
Then continue your db:push and db:pull workflow as usual.
(thanks to GantMan for the hint)
Since the taps servers will be decommissioned at some future point, the plugin is probably not the best long term solution. But of course you can run your own taps server.
Steps
Step 1: Start Your taps server
taps server `heroku config:get DATABASE_URL` db db
Step 2: Run the taps client
In a different shell:
taps pull sqlite://db/development.sqlite3 http://db:db#localhost:5000
Step 3: Shut down the taps server
Once the import is done you can shutdown the server with the normal Ctrl-C key combination.
Notes
This will pull my production database down into a local SQLite database. Of course if you are using MySQL or something locally just replace the sqlite URI with the equivalent MySQL URI.
Taps requires you to set a username/password. Since I am just running it locally for a short time I just use "db" for both. If you change these you will need to also update the username/password in the URL for step 2.
You can also use taps push to copy data to the production server although you should obviously do that with caution.
Taps has a number of bugs it has acquired over time due to the lack of activity by the maintainer:
The biggest annoyance is the fact that it stopped working after rack incorporated OKJson into Rack. The OKJson in Rack conflicts with the modified version that is included in taps. I created a patch to resolve this but no activity has been done to merge it. In the meantime workarounds include forcing taps to use an earlier rack. Paxa suggested an easy approach by modifying the bin/taps file. If you don't want to modify packaged installed files on your system you can also follow hax8or's instructions which use bundler to force the right version of Rack.
The progress bar does not render correctly. fd fixed this in his pull request but it has also not been merged in. Since this is purely cosmetic you can just ignore the bad output.
#wijet recently forked taps and incorporated some of the most important patches. He has named his gem "taps-taps" if you are looking for an easy out-of-the-box install.
This is still possible. Just run
heroku plugins:install https://github.com/heroku/heroku-taps.git
You'll be able to do your classic stuff, it's just a plugin now.
If you're having trouble still, you may need to make sure some other gems are installed. You can also run the following to be sure:
gem install heroku taps sequel
I hope this helps! I love db:push/pull just like the rest of the world, and I'm sad to see it go.
If you're still having problems take a look at this one: https://github.com/heroku/heroku-legacy-taps
GOODLUCK!
I used to use db:pull and it worked fine. After it was removed, I tried pg:pull but it is just not working for me.
I found a different solution.
If your local database is PostgreSQL, and you have the pgbackups addon enabled, this is the sequence of commands I'm using to copy the remote DB to my local machine:
$ wget "`heroku pgbackups:url --app app-name`" -O backup.dump
$ # Create the local database first, if it's not created yet. Then:
$ pg_restore -d database-name -c backup.dump -U database-user-name -O --no-acl -h localhost
Replace app-name, database-name and database-user-name with your own info.
You'll likely want to ask heroku to make a backup just before you pull your data:
heroku pgbackups:capture --expire
otherwise you get the data from whenever it did its own backup.
This is the error message I got when I tried db:pull.
db:pull is not a heroku command.
Perhaps you meant pg:pull.
See heroku help for a list of available commands.
Have you tried pg:pull?
Usage: heroku pg:pull <REMOTE_SOURCE_DATABASE> <LOCAL_TARGET_DATABASE>
Looks like db:pull etc is being deprecated & moved
See here https://github.com/heroku/heroku-pg-extras/issues/42
I found that the ability of db:push & pull to move single eg static tables of data up & down from dev to staging to production was invaluable - now looks like you need to create a new empty database and do an entire dump into it and then run pg commands to move an individual table
I found my answer here, but I put it in a rake task. I think this is a sensible way to deal with this situation. If you're running a local instance of postgres to work with your postgres on Heroku, you might try something like this:
# lib/tasks/database.rake
namespace :database do
desc "Gets the database from heroku and restores it to development"
task :pull => :environment do
dumpfile = 'tmp/latest.dump'
db_config = Rails.application.config.database_configuration[Rails.env]
File.delete(dumpfile) if File.exist?(dumpfile)
`heroku pgbackups:capture --app app-name-here`
system("curl -o #{dumpfile} `heroku pgbackups:url --app app-name-here`")
`pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{db_config['database']} #{dumpfile}`
end
end
Now, anytime I wish to pull my production data into dev I just run rake database:pull
This is a very rudimentary solution, but I only need it to do this one thing in my case.

Heroku Port 5000 not connecting

I am doing a Saas course from edx.org,using ruby on rails.
The course needs to deploy my app running in virtual box to heroku.
My host and guest machine are Ubutu 12.04
The problem is , this command does not work .
heroku run rails db:migrate
Even tried with troubleshooting on Heroku site ,which points the same above issue
https://devcenter.heroku.com/articles/oneoff-admin-ps#troubleshooting
But even this command did not work
telnet rendezvous.runtime.heroku.com 5000
It is clear port issue , I am unable to breakthrough.
Any help ?
If this is the error message:
$ heroku run console
Running `console` attached to terminal... up, run.2077
!
! Error connecting to process
$
Try this: heroku run:detached ls
If it says:
Running `ls` detached... up, run.8825
Use `heroku logs -p run.8825` to view the output.
$ heroku logs -p run.8825 2013-04-11T21:30:50.137946+00:00 heroku[run.8825]: Starting process with command `ls`
2013-04-11T21:30:50.805694+00:00 app[run.8825]: app
2013-04-11T21:30:50.805694+00:00 app[run.8825]: bin
2013-04-11T21:30:50.805694+00:00 app[run.8825]: config
.
.
.
Then it's firewall-related but only because Heroku points the finger elsewhere.
https://devcenter.heroku.com/articles/one-off-dynos
This is a Heroku issue for many users because they are demanding a connection to port 5000. In many enterprise environments where only ports 443/80/22 are usable, this leaves a large fraction of customers with lots of money out in the cold. Heroku should take ownership and just help users make it work. There is no technical reason they can't, and any argument as such would be to justify laziness.
Hackarounds like https://github.com/nzoschke/SSHeroku and charging for Proximo are non-starters, requiring more even more work diffused upon users and aren't scalable.
Heroku development servers appear to be down right now for me. Type the following code in the command line to output your log:
heroku logs
Right now I am getting error code h99 which they say on their website:
This indicates an internal error in the Heroku platform. Unlike all of the other errors which will require action from you to correct, this one does not require action from you. Try again in a minute, or check the status site.
The status site (status.heroku.com) says everything is okay... but my logs indicate there is something wrong on their end.
What does heroku logs output for you?

Resources