python - Heroku refuses connection to postgres database -
i trying deploy flask app based on postgresql on heroku, when try create table db.create_all()
keep getting error:
(psycopg2.operationalerror) not connect t rver: connection refused server running on host "localhost" (127.0.0.1) , accepting tcp/ip connections on port 5432?
here how code looks like:
app=flask(__name__) app.config['sqlalchemy_database_uri']='postgres://kfgriimpfjecsv:bk1*****g@localhost:5432/dd71doth8gopgh' db=sqlalchemy(app) if __name__ == '__main__': app.debug=true app.run()
i using heroku toolbelt communicate heroku servers. also, when try this:
psql -p 5432 -h localhost
i same error:
psql: not connect server: connection refused server running on host "localhost" (127.0.0.1) , accepting tcp/ip connections on port 5432?
i tried ec2-23-21-215-184.compute-1.amazonaws.com
instead of localhost
in uri, got same error.
and here complete traceback when run db.create_all():
any idea why connection being refused , how solve this?
it seems had append sslmode parameter database uri, changing second line following solved problem:
app.config['sqlalchemy_database_uri']= "postgresql+psycopg2://kfgriimpfjecsv:bk1*******g@ec2-23-21-215-184.compute-1.amazonaws.com:5432/dd71doth8gopgh?sslmode=require"
Comments
Post a Comment