App works locally but crashes on Heroku because of Databases connection

Hi all,

I’ve written my first app in Python but when I deployed it to Heroku, its crashed. It first works but when trying to connect it my database, it crashed. I think it’s mainly because my connection btw Heroku/PostGre SQL is not working and make make Heroku crash. I used PostGre SQL but still impossible to connect it to my Heroku Application. I read their tutorials but still returned an error. Don’t understand why. I’ve tried many changes within my code but still don’t understand why my app crash.

When I try to run the app, I get the following error within the heroku log :

2019-03-11T18:09:31.664752+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=iag-project.herokuapp.com request_id=b8b8bc79-2849-45be-9963-73381fc05d3c fwd=“193.29.202.4” dyno= connect= service= status=503 bytes= protocol=https

My code can be found here on Github in my repositories called IAG_project under profile Arthurmf01 (sorry freecodecamp didn’t allow me to share links as I’m new on the platform).

My code to connect it to GRE is like this as of now :

#%% Connect to Post GRE Database

#DATABASE_URL = os.environ[‘postgres://lkpxoehyppdlkg:4c57385d135e2c2f756696fa7961f0704c7f98a427f9d14b34769d4c14c489a3@ec2’]
#conn = pg.connect(DATABASE_URL, sslmode=‘require’)

conn = pg.connect(database=“postgres”, user = “postgres”,password = “”, host = “127.0.0.1”, port = “5431”)
print (“Opened database successfully”)
df = pd.read_sql_query(‘select * from “Test1_1”;’, conn)

As of now, my database consists of a giant CSV master file. I want to keep it simple for now. Then maybe make some connection. I know I could use google python API but my plan was to learn a bit on databases. The plan is to build visualization with the dash libraries on top of it afterward.

Any help/advice would be greatly appreciated…