This is my current init file, I already have the database model created on my models.py, but I don't think I have any issues with that. I just can't create my database table whenever I "db.create_all()" ... It gives me the error, I posted below.
- I have psycopg2 installed.
- I tried adding "localhost:5432" on my database_uri link, but that doesn't work either.
- I went into my postgres config file and changed "listen_addresses" from "*" to "::1, 127.0.0.1"
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SECRET_KEY'] = 'mysecretkey'
# DATABASE CONFIGS ---------------------------------------------------------------------------
db = SQLAlchemy(app)
ENV = 'dev'
if ENV == 'dev':
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:123456@localhost/flaskqna'
else:
app.debug = False
app.config['SQLALCHEMY_DATABASE_URI'] = ''
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
# DATABASE CONFIGS ---------------------------------------------------------------------------
from flaskqna import routes
THE ERROR
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
psql?