cant connect to pg locally
hypurrnating
HOBBYOP

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 file
project id: 1dfc4bb8-37ce-4e09-9723-387fa3324724

40 Replies

hypurrnating
HOBBYOP

2 years ago

the pghost seems to be railway.internal and not viaduct.railway like ive seen in the past


hypurrnating
HOBBYOP

2 years ago

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


hypurrnating
HOBBYOP

2 years ago

as i said before, the same script deploys fine on railway


hypurrnating
HOBBYOP

2 years ago

the script actually didnt work on railway before using variable references but like im sure i copied them properly


hypurrnating
HOBBYOP

2 years ago

What is love


hypurrnating
HOBBYOP

2 years ago

i do not understand the problem


hypurrnating
HOBBYOP

2 years ago

the pg database came out of sleep when i tried connecting so something must be have clicked


hypurrnating
HOBBYOP

2 years ago

but it wont connect


hypurrnating
HOBBYOP

2 years ago

the password is correct


hypurrnating
HOBBYOP

2 years ago

the user is correct


hypurrnating
HOBBYOP

2 years ago

the host is correct


hypurrnating
HOBBYOP

2 years ago

???


2 years ago

is the port correct?


hypurrnating
HOBBYOP

2 years ago

well yeah


hypurrnating
HOBBYOP

2 years ago

i tried the private one and the public one


hypurrnating
HOBBYOP

2 years ago

the private one i got by going to the variables tab and copying PGPORT and PGHOST


hypurrnating
HOBBYOP

2 years ago

and then public one i opened the Railway provided variables


hypurrnating
HOBBYOP

2 years ago

and copied the RAILWAY_TCP_PROXY_DOMAIN:RAILWAY_TCP_PROXY_PORT for PGHOST and then RAILWAY_TCP_APPLICATION_PORT for PGPORT


hypurrnating
HOBBYOP

2 years ago

neither work


2 years ago

you have it pointing to the wrong port

1272302380595150800


hypurrnating
HOBBYOP

2 years ago

should i point it to 5432


2 years ago

yep thats the port postgres is running on


hypurrnating
HOBBYOP

2 years ago

i think even the first tcp proxy (which i didnt create) was running on the wrong port


hypurrnating
HOBBYOP

2 years ago

cause it was 45117


hypurrnating
HOBBYOP

2 years ago

anyways


2 years ago

that would have been something you changed at some point


hypurrnating
HOBBYOP

2 years ago

1272303227802615800
1272303228003815400


hypurrnating
HOBBYOP

2 years ago

still doing a getaddr info fail


2 years ago

you need to use the public host as the host and the public port as the port


hypurrnating
HOBBYOP

2 years ago

yeah

1272303475111497700


2 years ago

you arent…


hypurrnating
HOBBYOP

2 years ago

🙏


hypurrnating
HOBBYOP

2 years ago

its working now


2 years ago

awsome


hypurrnating
HOBBYOP

2 years ago

enabling app sleeping on pg and redis should be fine tho right?


2 years ago

as long as your client can handle retries


hypurrnating
HOBBYOP

2 years ago

alr


hypurrnating
HOBBYOP

2 years ago

i see


hypurrnating
HOBBYOP

2 years ago

tysm


2 years ago

bo problem


Loading...