4 months ago
(.venv) PS C:\Users\mceza\Dropbox\PROGRAMACAO\PYTHON\FRAMEWORKS\DJANGO\Django_Railway_PostgreSQL> python manage.py shell
9 objects imported automatically (use -v 2 for details).
Python 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.37.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import os
...: from django.conf import settings
...: print("URL:", os.getenv("DATABASE_URL"))
...: db = settings.DATABASES["default"].copy()
...: db["PASSWORD"] = "***"
...: print(db)
...:
...: from django.db import connection
...: with connection.cursor() as c:
...: c.execute("SELECT 1")
...: print(c.fetchone())
...:
URL: postgresql://postgres:password@yamabiko.proxy.rlwy.net:12766/railway?sslmode=require
{'ENGINE': 'django.db.backends.postgresql', 'USER': 'postgres', 'PASSWORD': '***', 'HOST': 'yamabiko.proxy.rlwy.net', 'PORT': 12766, 'NAME': 'railway', 'OPTIONS': {'sslmode': 'require', 'connect_timeout': 10, 'keepalives': 1, 'keepalives_idle': 20, 'keepalives_interval': 5, 'keepalives_count': 5}, 'CONN_MAX_AGE': 0, 'CONN_HEALTH_CHECKS': True, 'DISABLE_SERVER_SIDE_CURSORS': False, 'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'TIME_ZONE': None, 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIGRATE': True, 'MIRROR': None, 'NAME': None}}
---------------------------------------------------------------------------
OperationalError Traceback (most recent call last)
File ~\Dropbox\PROGRAMACAO\PYTHON\FRAMEWORKS\DJANGO\Django_Railway_PostgreSQL\.venv\lib\site-packages\django\db\backends\base\base.py:279, in BaseDatabaseWrapper.ensure_connection(self)
278 with self.wrap_database_errors:
--> 279 self.connect()
File ~\Dropbox\PROGRAMACAO\PYTHON\FRAMEWORKS\DJANGO\Django_Railway_PostgreSQL\.venv\lib\site-packages\django\utils\asyncio.py:26, in async_unsafe.<locals>.decorator.<locals>.inner(*args, **kwargs)
25 # Pass onward.
---> 26 return func(*args, **kwargs)
File ~\Dropbox\PROGRAMACAO\PYTHON\FRAMEWORKS\DJANGO\Django_Railway_PostgreSQL\.venv\lib\site-packages\django\db\backends\base\base.py:256, in BaseDatabaseWrapper.connect(self)
255 conn_params = self.get_connection_params()
--> 256 self.connection = self.get_new_connection(conn_params)
257 self.set_autocommit(self.settings_dict["AUTOCOMMIT"])
File ~\Dropbox\PROGRAMACAO\PYTHON\FRAMEWORKS\DJANGO\Django_Railway_PostgreSQL\.venv\lib\site-packages\django\utils\asyncio.py:26, in async_unsafe.<locals>.decorator.<locals>.inner(*args, **kwargs)
25 # Pass onward.
---> 26 return func(*args, **kwargs)
File ~\Dropbox\PROGRAMACAO\PYTHON\FRAMEWORKS\DJANGO\Django_Railway_PostgreSQL\.venv\lib\site-packages\django\db\backends\postgresql\base.py:332, in DatabaseWrapper.get_new_connection(self, conn_params)
331 else:
--> 332 connection = self.Database.connect(**conn_params)
333 if set_isolation_level:
File ~\Dropbox\PROGRAMACAO\PYTHON\FRAMEWORKS\DJANGO\Django_Railway_PostgreSQL\.venv\lib\site-packages\psycopg2\__init__.py:122, in connect(dsn, connection_factory, cursor_factory, **kwargs)
121 dsn = ext.makedsn(dsn, **kwargs)
--> 122 conn = connect(dsn, connectionfactory=connection_factory, **kwasync)
123 if cursor_factory is not None:
OperationalError: connection to server at "yamabiko.proxy.rlwy.net" (35.212.113.203), port 12766 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
3 Replies
4 months ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Unable to Connect to postgres.railway.internal (Connection Timed Out)
🧵 PostGIS Connection Timeouts: Can't Connect Django Service Despite Correct Variables
If you find the answer from one of these, please let us know by solving the thread!
Status changed to Completed mahmoud-railway • 4 months ago
Railway
Hey there! We've found the following might help you get unblocked faster: - [🧵 OperationalError - connection to server at "<...>.proxy.rlwy.net" (), port failed: Connection timed out](https://station.railway.com/questions/operational-error-connection-to-server-a6ddcb5b) - [🧵 Unable to Connect to postgres.railway.internal (Connection Timed Out)](https://station.railway.com/questions/unable-to-connect-to-postgres-railway-in-78a1a604) - [🧵 PostGIS Connection Timeouts: Can't Connect Django Service Despite Correct Variables](https://station.railway.com/questions/post-gis-connection-timeouts-can-t-conne-0d0c570a) If you find the answer from one of these, please let us know by solving the thread!
4 months ago
Didn't solve it
4 months ago
What is the solution to the problem?