The project is a django web app, packed on docker containers. For some reason, I cannot run the server and launch it.
when I run "manage.py runserver", this error occurs:
File "C:\Users\andre\AppData\Local\Programs\Python\Python310\lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: connection to server at "158.160.17.21", port 5432 failed: Connection refused (0x0000274D/10061)
Is the server running on that host and accepting TCP/IP connections?
What do you think can be done with it? Thank you.
The first line of your error tells me that you're using a locally installed copy of psycopg2, a Python client library for PostgreSQL, to connect to the database. This is happening behind the scenes when Django needs to make that connection, but it's interesting that it's installed locally, rather than in a docker container, given you said your Django webapp is running in Docker.
The third line of your error is very simple: it tells you that
the programme is expecting Postgres to be served on a machine with the IP address 158.160.17.21 on port 5432 (the default port for Postgres)
it isn't there
Now, this IP address is not a default and doesn't refer to your own machine, so it must be something you've provided. An IP lookup suggests it's in Venezuela (does that sound right to you?). Perhaps you are expecting Postgres to be served on a third party machine; if so, you'll need to check that you have the right IP address and that Postgres is being served there.
Otherwise, you'll need to reconfigure Django to seek Postgres elsewhere.
Open Task Manager > Services tab > Right-Click on Mongo > Start.
Now go re-run the server again.
Related
i want to connect a python code with a database localized in a Google Cloud Platform PostgreSQL database. I've been running this code and this working correctly, but recently i chaged me server to a VPS provided by a host. Now when i try to connect to the database with python3 i receive the follow message:
Psycopg2.OperationalError: could not connect to server: Connection timed out
Is the server running on host "35.199.90.49" and accepting
TCP/IP connections on port 5432?
I have authorized the IP of the server in the Google Cloud Platform, i tried to open all IPv4 address too, but nothing is working. I changed the /XX from IPv4 for my server. I disabled the firewall of the server. Nothing is working but when i connect with the psql command at ubuntu server, the database connection is okay.
I have an existing database (Postgres) that i want to connect to apache-Airflow on my host machine(Windows 10), I installed the apache-airflow on the WSL running ubuntu. The installation was smooth and working fine since i was able to get the airflow webserver running on my localhost(port:8081).
I tried connecting airflow to my existing database (carPrices) passing all the necessary parameters which were all correct. I also confirmed my database is up and running on port(5432). Whenever i click the connect button it will report this error..."could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?"
I dont know what exactly is the problem as i am new to airflow.
I tried setting the connection parameter of airflow by setting it through the airflow.cfg file and through the Airflow UI home. In the first case i cant even "airflow db init" as it report the same problem of connection refusal. the second case will setup a default sqlite db for the airflow UI to run. then i tried connecting using the UI but same error message was given.
I check using if the postgres is up and running using netstat -ab and posgres is up and listening.
I was expecting the connection to report succesful since i am sure of all the database parameters passed but instead i got this.
Found out the problem is with WSL 2, you cant connect to localhost from WSL2 without some complicated tweaks... The simplest thing to do is downgrade to WSL 1
running this command in powershell:
wsl.exe --set-version Ubuntu-20.04 1
I have a discord.py bot and I host it on Google Cloud RDP (windows). I was working and testing PostgreSQL database on my local computer and it was working like charm now when I tried to use the same code and same connection method on my RDP, I got an error.
This is how I connect to database on my local pc:
How do I connect it with RDP now? Do I need to make any changes to the database like whitelisting the IP and if so How do I do it?
Thanks
If the database is running on your local computer inside your firewall/router, then it cannot be reached from the Internet. If you control your router, you can try forwarding port 5432 on your public IP to port 5432 on your Windows computer. However, it might be better if you just moved the Postgres instance to your cloud instance.
I'm writing here because I can't find any other information on this specific bug.
Whenever I try to connect to my remote DB using
engine = sqlalchemy.create_engine(f'mysql+pymysql://{creds.user}:{creds.dbpassword}#{creds.host}:{creds.port}/{creds.database}')
It tells me:
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] No connection could be made because the target machine actively refused it)")
(Background on this error at: http://sqlalche.me/e/e3q8)
I explicitly have creds.host set to the IP of the sever as well as I get the same error when I put it directly into the engine. This works on the remote machine under root but does not work for me and it works for a partner who runs the exact same code. Some of the links I found was suggesting to change the bind-address in the mysql config. I uninstalled my local mariadb/mysql server and went and found the config file with bind-address and uncommented it so it was bind-address=0.0.0.0 after a reboot its still not working so I have to think that it is my machine that is not letting me connect to the server.
New info: My partner can no-longer connect through pymysql. I can still connect through datagrip and mysql workbench. The port is open and mysql is listening on port 3306. I have appropriate permissions as I know this because I can connect through datagrip and mysql workbench. I'm thinking this is an us problem and not a server problem but I just don't know why because nothing has changed before the issue started.
I launched an AWS linux instance and installed and ran mongo as instructed here. The mongo service is running and accepting connections on 27017. However, when I go to the server publik dns with port 27017 the server does not respond and I don't see the default mongo message.
I am trying to run a Python(Flask) server on another instance and trying to connect to the mongo server using the private ip, but the connection does not happen. I get this error message on the terminal :
pymongo.errors.ServerSelectionTimeoutError: xxx.xx.xx.xx:27017: [Errno
111] Connection refused
Is this not the right way to use mongo db on aws ? If this approach is feasible, what is causing the connection to not happen ?
All inputs appreciated, much thanks!
It is possible that your mongodb is configured to only accept connection from local host. Edit /etc/mongod.conf file to comment out the line that bindIP like in the example below -
# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.