I have a weird problem. I can connect to a remote host using psql from the command line but can’t using the exact same credentials in a django settings file. I get the error:
Could not connect to server: Permission denied Is the server running
on host “remote ip” and accepting TCP/IP connections on port
port_number?
If I can connect using psql and not using django what am I missing here? I also checked through python interpreter that I can load psycopg2.
Any help is greatly appreciated as non of what I’ve found online has helped.
Cheers,
D
Here’s the db conf in settings.py
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '<db name goes here>', # Or path to database file if using sqlite3.
'USER': '<db user>', # Not used with sqlite3.
'PASSWORD': '<pswd goes here>', # Not used with sqlite3.
'HOST': '<remote ip goes here>',
'PORT': '5432',
}
Based on your description this has something to do with the Apache and it’s permissions to access the database. You didn’t mention which OS you use but if it is running SELinux the default rules prevent apache from connecting to db. If this is the case you can temporarily enable it by running:
Here are more detailed instructions.