R
Railwayβ€’4w ago
sunrise

cant connect to pg locally

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.
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:
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
Solution:
you need to use the public host as the host and the public port as the port
Jump to solution
20 Replies
Percy
Percyβ€’4w ago
Project ID: 1dfc4bb8-37ce-4e09-9723-387fa3324724
sunrise
sunriseβ€’4w ago
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 as i said before, the same script deploys fine on railway the script actually didnt work on railway before using variable references but like im sure i copied them properly What is love i do not understand the problem the pg database came out of sleep when i tried connecting so something must be have clicked but it wont connect the password is correct the user is correct the host is correct ???
Brody
Brodyβ€’4w ago
is the port correct?
sunrise
sunriseβ€’4w ago
well yeah i tried the private one and the public one the private one i got by going to the variables tab and copying PGPORT and PGHOST and then public one i opened the Railway provided variables and copied the RAILWAY_TCP_PROXY_DOMAIN:RAILWAY_TCP_PROXY_PORT for PGHOST and then RAILWAY_TCP_APPLICATION_PORT for PGPORT neither work
Brody
Brodyβ€’4w ago
you have it pointing to the wrong port
No description
sunrise
sunriseβ€’4w ago
should i point it to 5432
Brody
Brodyβ€’4w ago
yep thats the port postgres is running on
sunrise
sunriseβ€’4w ago
i think even the first tcp proxy (which i didnt create) was running on the wrong port cause it was 45117 anyways
Brody
Brodyβ€’4w ago
that would have been something you changed at some point
sunrise
sunriseβ€’4w ago
No description
No description
sunrise
sunriseβ€’4w ago
still doing a getaddr info fail
Solution
Brody
Brodyβ€’4w ago
you need to use the public host as the host and the public port as the port
sunrise
sunriseβ€’4w ago
yeah
No description
Brody
Brodyβ€’4w ago
you arent...
sunrise
sunriseβ€’4w ago
πŸ™ its working now
Want results from more Discord servers?
Add your server