Having issue connecting to a Python (uvicorn) internal app through Golang app
So, I have a Python app that runs a uvicorn + FastAPI server. I don't want to expose it to a public network, I only need to use it internally. It's working fine. I also have a Go app that consumes info from this Python server. When I try to ping the server with this code:
url
param is the Private Networking URL you automatically assigned. I tried adding "http://" prefix, removing it, adding :80 port, etc but it's not working unfortunately. I'm getting this error message:
Get \"http://gostock-python-sv.railway.internal/ping/\": dial tcp [fd12:1e3f:72a3::2c:a44e:2e7]:80: connect: connection refused
The server is working fine. If I expose it to the public network, I can access to it. If I remove the HTTP scheme, I get this error:
Get \"gostock-python-sv.railway.internal/ping/\": unsupported protocol scheme \"\"
Project ID: 7d9659a4-cd22-47d5-b1f7-ed6ce4247406
Any help on this, please?Solution:Jump to solution
should I set something like this:
web: uvicorn main:app --host='::' --port=${PORT:-5000}
in my Procfile?...13 Replies
Project ID:
7d9659a4-cd22-47d5-b1f7-ed6ce4247406
what port is the python app listening on?
initially it was on 5000, then I tried with 80, still the same problem
keep it on a non privileged port for good measure
is uvicorn listening on
::
aka all hosts both ipv6 and ipv4, since the internal network is ipv6 onlySolution
should I set something like this:
web: uvicorn main:app --host='::' --port=${PORT:-5000}
in my Procfile?currently I'm using this:
web: uvicorn main:app --host=0.0.0.0 --port=${PORT:-5000}
im not completely sure thats valid, but worth a shot
tried using above command with
::
, I got these logs:
still getting this error when pinging the server:
"Get \"http://gostock-python-sv.railway.internal/ping/\": dial tcp [fd12:1e3f:72a3::1a:fd7c:7c42]:80: connect: connection refused"
uvicorn is running on port 7862 but you are trying to make a request with port 80
in the python's service variables set PORT to 8080, or some other 4 digit number, then make requests with that port
I thought
::
would make it accessible no matter the port, my bad
will try again!thats just any interface, not any port
it's working now, with
::
and a fixed port, thx a lot!
:)no problem!