I have an app up and running on heroku connected to it's own database, however i have a database in my own server which is free and I want to connect my app to it, I changed my Gemfile accordingly but it seems to just ignore it.
I tried
heroku config:add DATABASE_URL=url
but it said he couldn't replace the existing DATABASE_URL...
You can either do this via the command line by first removing and then adding the variable:
heroku config:remove DATABASE_URL
heroku config:add DATABASE_URL=http://someurl.com
or you can do this via the heroku dashboard.
Select your app
Go to Settings
Reveal config variables
Change your DATABASE_URL
Related
I am coming in late to add some functionality to an already existing app hosted on heroku. The original builder has given me access and I 'heroku git:clone -a app-name' to my local computer.
I've found some conflicting instructions on how to set up a staging environment for this site. I don't want to push to the original site but want a way to try out functionality.
If anyone has had experience with staging and heroku, I'd appreciate any clarification.
You'll need to create a staging.rb file in config/environments. You can copy development.rb or production.rb and adjust whatever values you need.
Heroku will handle configuring the database configuration and such. You can clone an app in Heroku or just create a new one, then set it's RAILS_ENV and RACK_ENV environment variables to staging, and push to it.
Please refer: Heroku - Managing Multiple Environments for an App
You Need to create a second Heroku application that hosts your staging application.
Follow the instructions provided in the link for working with multiple environment in heroku.
I have remotes to two heroku apps, one for staging and one for production. I am encountering a strange permission denied error when I try to target one of the apps. For example, if I run:
heroku logs --app staging
I get back:
! You do not have access to the app staging.
However, if I simply change the command to:
heroku logs --remote staging
it works fine. Of course this isn't a huge inconvenience, but I would like to be able to use the --app extension without permission issue. If anyone has encountered this before, or has any ideas as to why this may be, please let me know :).
Thanks!
These two options use entirely different mechanisms to lookup the Heroku app by 1) git remote name 2) heroku app name.
When you say --app staging you are looking up an app called staging which you do not own, and getting a permission denied.
When you use the --remote staging you are looking up the app attached to your git remote called staging and it works.
The right way to use --app is with --app your-app-name, since staging is not your app.
I've deployed an app to Heroku, and I'm currently storing my environment variables in an .env file. I used heroku config:push to push the variables up to heroku, and that worked fine.
Now, I want to update one of them. I changed it in my .env file, and ran heroku config:push again. The push said it was successful, but when I run heroku config, I can see that the values actually haven't changed. I've tried running heroku restart, but that didn't do anything.
How can I update my environment variables in heroku?
Figured it out. You need to run heroku config:push --overwrite because it won't overwrite existing variables by default. This is poorly documented :-/
Is it possible to retrieve the app id (app123#heroku.com) within the application environment?
I know, that I can manually set a config var, but I figured such info could be exposed by Heroku?
If you have an add-on like SendGrid or Memcache installed, you can access the environment variables for the username of one of those add-ons. For example, if you were using Ruby, you can log into the console and output the value of ENV['SENDGRID_USERNAME'] or ENV['MEMCACHE_USERNAME']. It's easy to extract the app id from there. I'm not sure which other add-ons also expose that value in an environment variable but you can output the entire ENV global hash and find out what's available.
I used Jared's solution for over a year.
Today I ran into an issue when ENV['SENDGRID_USERNAME'] was not there yet (during deployment).
Heroku recommends to set a config var for this yourself, so I set:
heroku config:add APP_NAME=<myappname> --app <myappname>
And enable lab feature that allows you to use them during compile
heroku labs:enable user-env-compile -a myapp
And now I have my app name available here:
ENV["APP_NAME"] # '<myappname>'
So I won't run into the issue again, though I would like to get this kind of info set from Heroku instead.
This is straight from my support ticket with Heroku:
You cannot retrieve that value yourself. This is a value that SendGrid support requires that only Heroku support can supply to them.
So you will need to ask Heroku for it via a support ticket
UPDATE
Somewhat contradictorily, I found I could access my Heroku app id by running:
heroku config:get SENDGRID_USERNAME
app171441466#heroku.com
Here's the story, my heroku site was originally using the 5mb shared postgres db with no problems. I had a valid SHARED_DATABASE_URL and no DATABASE_URL
Then I added a config var by doing
heroku config:add DATABASE_URL=non_existing_database_just_for_fun
Just to see if it would switch from the shared db to this new one I just set. It did just that, and promptly crashed my app as expected since no valid database was found.
Then I did heroku config:remove DATABASE_URL hoping to get my site back to normal. But now it keeps crashing and never succeeds in starting up. If I do a heroku config I see that I still have a valid SHARED_DATABASE_URL and no DATABASE_URL but the site still wont work.
I did get it working by setting up DATABASE_URL to match SHARED_DATABASE_URL but I'd like to get it back to how things were originally, the site working without needing DATABASE_URL. Any ideas no how I can get things back to the way they were short of having to reinstall my site?
DATABASE_URL is the key that Heroku expect you to use for your database connectivity. They will not touch this value unless you ask them to (aside from initial setup).
The SHARED_DATABASE_URL is the URL of the shared database that they have provided to you.
By default, Heroku set your DATABASE_URL to match your SHARED_DATABASE_URL.
I'm not entirely sure why would would want your application to not have a DATABASE_URL, as that's what's used. If you look at the bottom of this, you can see what they do with your config/database.yml and how it affects your application.