How to Access Remote PostgreSQL Database Server Through VPN - django

I'm currently working with my office server, when i want to connect to the server, i have to use their VPN. I have installed PostgreSQL database in their server and have succesfully migrate data to database from Django project. But, when i want to remote access from HeidiSQL, it always gives me Connection Timed Out Error eventhough i have already connected to their VPN.
I've tried to this code below
/var/lib/pgsql/14/data/pg_hba.conf
host all all 0.0.0.0/0 md5
host all all ::/0 md5
/var/lib/pgsql/14/data/postgresql.conf
listen_addresses = '*'
i have tried to refresh everytime i change files and see if i'm in the correct port but it still gives me Connection Timed Out Error
this is the full error message
could not connect to server: Connection Timed out (0x0000274C/10060). Is the server running on host "xxx.xxx.xxx.xxx" and accepting TCP/IP connections on port 5432 ?
NOTES
OS : CentOS 8
DB : PostgreSQL 14

Related

connection to server at "localhost" (127.0.0.1), port 5432 failed

I am facing this error "OperationalError at /results/
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
Is the server running on that host and accepting TCP/IP connections?" when I try to run a django application that I just deployed in railway.app.
What is the problem and how can I fix?
When I run the application locally it works well, it is my first time deploying a django application to production and I have no idea how to solve that issue, your help is greatly appreciated.
I just realized that the error is due to not using railway's database. Apparently it was running localhost and my postgres' port, created a postgres database in railway and connected to the deployed django app and it is now working well. Thank you #Laurenz Albe for reminding me that.

How do I connect my Django App to Postgres Databse?

How do I connect my Django App to Postgres Databse?
Whenever I run python manage.py makemigrations after the changes, then I get this kind of error. How can I fix it?
Got an error checking a consistent migration history performed for database connection 'default': connection to server
at "localhost" (::1), port 5432 failed: Connection refused (0x0000274D/10061)
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused (0x0000274D/10061)
Is the server running on that host and accepting TCP/IP connections?
warnings.warn(
No changes detected
Seems like your postgres server is not running. I would suggest you to ensure that postgres server is running and you are able to connect to it.
You can use your terminal or any DB tool like PgAdmin, DBeaver, Tableplus etc.
After you are able to connect to your database through any of the above mentioned ways. Django db connection should not be a problem.
You can take help from
https://tableplus.com/blog/2018/10/how-to-start-stop-restart-postgresql-server.html
https://www.enterprisedb.com/postgres-tutorials/connecting-postgresql-using-psql-and-pgadmin

Connecting to Could SQL from local machine via proxy

I am following these instructions to deploy a Django app on Google App Engine:
https://cloud.google.com/python/django/appengine
I have got as far as downloading the proxy .exe file (I am on a Windows machine) and connecting to it:
2019/01/08 16:14:08 Listening on 127.0.0.1:3306 for
[INSTANCE-NAME] 2019/01/08 16:14:08
Ready for new connections
When I try and create the Django migrations by running python manage.py createmigrations I see the connection received by the proxy file:
2019/01/08 16:15:06 New connection for
"[INSTANCE-NAME]"
However, after a couple of seconds pause I get this error:
2019/01/08 16:15:28 couldn't connect to
"[INSTANCE-NAME]": dial tcp
35.205.185.133:3307: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have tried disabling my local firewall in case this was causing any issues, but the result is the same. I've also checked the username, password and Cloud SQL instance name, they are all correct.
What could be causing this error?

PostgreSQL: could not connect to server: Connection refused

I have a Django project, I want to switch from SQLite to PostgreSQL.
After installation, I can't run the command psql
Here is the traceback:
psql: 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?
OS: Windows
TCP/IP connections are not enabled by default, so you probably have to edit a file called postgres.conf:
vi /etc/postgresql/9.4/main/postgresql.conf
For you it may reside in a different location. Look for a line saying:
#listen_addresses = '' # what IP address(es) to listen on;
Change it to this:
listen_addresses = '*' # what IP address(es) to listen on;
Right under this there's the port setting. For me it reads:
port = 5432 # (change requires restart)
Higher up in the same file there is a reference to another config file:
hba_file = '/etc/postgresql/9.4/main/pg_hba.conf' # host-based authentication file
Go ahead and edit that file. You should insert a line like this:
host all all 192.168.1.0 255.255.255.0 trust
Your IP may be different. (Once you ensure this is working, you can change "trust" to "md5" for better security.) After doing this, you need to restart the postgres server.
/usr/lib/postgresql/9.4/bin/pg_ctl restart

Postgresql localhost connection - Connection refused

i just installed pgadmin iii and try to connect server.
I configured my setting
name:localhost
host: 127.0.0.1
port:5432
username:postgres
but i always get this error
The server doesn't accept connection: the connection library reports
**could not connect to server : Connection refused Is server runing on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
However, i'm runing django and python on 127.0.0.1 What's missing?
There's also a problem with mysql. I could not connect with them
If you change the pg_hba.conf file to accept connections (for example: "host all all 127.0.0.1 255.255.255.0 trust") it should work
Installing postgre v12 before uninstalling v11 I found the config file (postgresql.conf) had a line "port = 5433". Changing this to "port = 5432" fixed the issue for me.