I'm using Oracle 11g and Django 1.5.1.
I have installed cx_Oracle, import cx_Oracle works fine.
I setup database settings like this:
DATABASES = {
'default' : {
'ENGINE' : 'django.db.backends.oracle',
'NAME' : 'XE',
'USER' : 'system',
'PASSWORD' : 'mypass',
'HOST' : '127.0.0.1'
'PORT' : '1521'
}
}
When I said
python manage.py syncdb
it said
DatabaseError: ORA-12170: TNS:Connection timeout occurred.
I can connect to database with Navicat.
This error means it was unsuccessful in making a tcp connection to 127.0.0.1 port 1521
As root, or the user running the Oracle database, what address is shown for the LISTENing port in the output of lsof -Pni:1521
If it is not 127.0.0.1:1521 or *:1521, then it won't be listening on 127.0.0.1
However. This is a connection timeout, not something like port unreachable (connection refused)
You didn't say if you were running navicat from the same machine or a different machine. If the above command shows only 127.0.0.1:1521, then it's only listening on that IP address, and would need to be changed to allow connections from other machines, if that is what you are trying to achieve.
Check for firewall rules that may block traffic.
If attempting to connect remotely, doing a network trace can be useful to determine the problem. I recently had an issue similar to this that caused ARP to malfunction. You can see how I diagnosed that particular issue at http://distracted-it.blogspot.co.nz/2014/04/ora-12170-tnsconnect-timeout-resolved.html
Related
Hello I just want to deploy my django project in python anywhere .... and when I run the command python manage.py migrate
it shows this error message django.db.utils.OperationalError: connection to server at "<Host name>" (<IP address>), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?
I think that the problem in python anywhere because when I connect to the server in pgadmin using the same info in the settings.py file I don't get any error messages and you have to know that I am using neon.tech for my postgresql database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '<the database>',
'USER':'<User>',
'PASSWORD':'<Password>',
'HOST':'<Host>',
'PORT':5432,
}
}
and I am sure that all information is right because I used it to connect to the server in pgadmin in my local machiene
If you are having trouble connecting to a PostgreSQL database in a deployment environment, there are a few things you can check:
Verify that the database is running: Make sure that the PostgreSQL database is running and accessible from the deployment environment. You can check this by attempting to connect to the database using the 'psql' command-line tool.
Check the connection settings: Ensure that the connection settings in your deployment configuration are correct, including the database host, port, database name, user, and password.
Check firewall settings: If you are connecting to a remote PostgreSQL database, ensure that the necessary firewall ports are open to allow incoming connections to the database server.
Check for network issues: Check for any network issues that may be preventing the deployment environment from connecting to the database. For example, if you are deploying to a virtual private cloud, ensure that the network settings are configured correctly.
Check for authentication issues: Make sure that the user and password specified in the connection settings have the necessary permissions to access the database.
Check logs for errors: Check the logs for any error messages that may indicate the cause of the connection issue.
By investigating the above points, you should be able to narrow down the cause of the connection issue and take the necessary steps to resolve it.
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
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
I have changed the Django Settings file database engine to postgres_psycopg2.
When I run ./manage.py run server I get the following error numerous times:
"[03/Apr/2019 18:40:09] code 400, message Bad request version
('error",
"name":"DatabaseError",
"code":"ECONNREFUSED",
"property":null,
"redirect":null,
"errno":"ECONNREFUSED",
"syscall":"connect",
"address":"127.0.0.1",
"port":3306,"fatal":true}}'
)
For some reason it is trying to connect to port 3306, which is the Mariadb port and not port 5432, which is the port for Postgresql.
I just upgraded my Mariadb to version 10.3.14 but the problem still exists. My Postgresql is version 11.2.
I have been Googling for several days now and still have not found a solution.
EDIT: I changed the "./manage.py runserver 192.168.1.109:8000/admin" and the error went away. In my /etc/mysql/my.cnf file it had the bind_address set to the above ip address. I comment out that statement and now all is cool.
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?