Forums

Getting internal server error when i use postgresql

Hi,

When i use below code,

app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://akiltepe-xxxx.postgres.pythonanywhere-services.com"

i am getting an internal server error: 500

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "akiltepe-xxxx.postgres.pythonanywhere-services.com" (10.0.0.64), port 5432 failed: Connection refused

011Is the server running on that host and accepting TCP/IP connections?

i think have imported and installed psycopg2 module correctly.

I am thankful for all your future help.

Your server is not listening on port 5432. On the "Databases" page you will find correct port for your server.

Thank you for your kind answer,

However; whatever i do to change the listening port, i couldn't manage to do it. Could you please provide a walkthrough for the mentioned action?

Sincerely

You need to specify the port in your connection string as it is shown on your Databases page:

"postgresql://akiltepe-xxxx.postgres.pythonanywhere-services.com:port_number"