Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9314855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:14:27+00:00 2026-06-19T02:14:27+00:00

My code works locally, but when I try running it on Heroku it does

  • 0

My code works locally, but when I try running it on Heroku it does not work.I have added a db on heroku, but it still won’t work. Any clues to why this happens?

import sys
import os

from flask import Flask, render_template
from flask.ext.sqlalchemy import SQLAlchemy

db_local =   #it works, just not shown here

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', db_local)

app.secret_key = '  '  #it's a secret for a reason

db = SQLAlchemy(app)

from views import *
from model import *
db.create_all()

if __name__ == '__main__':
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port, debug=True)

Some of my heroku logs

2013-02-19T22:29:59+00:00 app[web.1]:   File "app.py", line 23, in <module>
2013-02-19T22:29:59+00:00 app[web.1]:     from views import *
2013-02-19T22:29:59+00:00 app[web.1]:   File "/app/views.py", line 1, in <module>
2013-02-19T22:29:59+00:00 app[web.1]:     from app import db
2013-02-19T22:29:59+00:00 app[web.1]:   File "/app/app.py", line 25, in <module>
2013-02-19T22:29:59+00:00 app[web.1]:     db.create_all()
2013-02-19T22:29:59+00:00 app[web.1]:     self._execute_for_all_tables(app, bind, 'create_all')
2013-02-19T22:29:59+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy.py", line 822, in create_all
2013-02-19T22:29:59+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy.py", line 814, in _execute_for_all_tables
2013-02-19T22:29:59+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/schema.py", line 2564, in create_all
2013-02-19T22:29:59+00:00 app[web.1]:     import utils
2013-02-19T22:29:59+00:00 app[web.1]:   File "/app/utils.py", line 1, in <module>
2013-02-19T22:29:59+00:00 app[web.1]: Traceback (most recent call last):
2013-02-19T22:29:59+00:00 app[web.1]:     conn = self.contextual_connect(close_with_result=False)
2013-02-19T22:29:59+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2490, in contextual_connect
2013-02-19T22:29:59+00:00 app[web.1]:     self.pool.connect(), 
2013-02-19T22:29:59+00:00 app[web.1]:     tables=tables)
2013-02-19T22:29:59+00:00 app[web.1]:     con = self._create_connection()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:14:28+00:00Added an answer on June 19, 2026 at 2:14 am

    I imagine the value of DATABASE_URL in your config vars does not exist. You can verify this via heroku config:get DATABASE_URL --app your-app

    Try heroku pg:info --app your-app to find out what databases you have installed. Make sure your database is also DATABASE_URL (it would also show up in the output of pg:info). If it’s not, just run heroku pg:promote HEROKU_POSTGRESQL_<color> --app your-app and try your script again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following line of code which works fine locally, but breaks when
Locally everything works fine, but on a remote Weblogic not really. The next code
Q: The following code works very well locally but when i try on server
This code works fine, but I'll want to handle exception if any thing goes
The following code works fine under Cassini, but not at all under IIS. I
I usually test my code locally on my work machine and then move it
This code works well for displaying separate xml items in my main.xml. But is
So, here is the scenario: I have Neo4J server running locally with some data
i have the following code below (i have stuck in xxx to not publish
I have some unit tests that use Azure Storage. When running these locally, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.