2 years ago
so im trying to connect to my postgres server locally from a python script using asyncpg.create_pool
this has always worked for me in the past but its not working this time for some reason.py async with asyncpg.create_pool(database=os.environ.get('PGDATABASE'), host=os.environ.get('PGHOST'), user=os.environ.get('PGUSER'), password=os.environ.get('PGPASSWORD'), port=os.environ.get('PGPORT')) as psql:
the env variables are all present.
i get socket.gaierror: [Errno 11001] getaddrinfo failed. if you want me to send full traceback i can do that ig.
it works fine on railway idk it just doesnt work on my computer.
the env variables for the project on railway are variable references, and ive copied those to the local env fileproject id: 1dfc4bb8-37ce-4e09-9723-387fa3324724
40 Replies
the pghost seems to be railway.internal and not viaduct.railway like ive seen in the past
i did go to the pg server settings and find the public networking url which was viaduct.railway but it gives me the same error
the script actually didnt work on railway before using variable references but like im sure i copied them properly
the pg database came out of sleep when i tried connecting so something must be have clicked
2 years ago
is the port correct?
the private one i got by going to the variables tab and copying PGPORT and PGHOST
and copied the RAILWAY_TCP_PROXY_DOMAIN:RAILWAY_TCP_PROXY_PORT for PGHOST and then RAILWAY_TCP_APPLICATION_PORT for PGPORT
2 years ago
you have it pointing to the wrong port

2 years ago
yep thats the port postgres is running on
i think even the first tcp proxy (which i didnt create) was running on the wrong port
2 years ago
that would have been something you changed at some point
2 years ago
you need to use the public host as the host and the public port as the port
2 years ago
you arent…
2 years ago
awsome
2 years ago
as long as your client can handle retries
2 years ago
bo problem


