Able to make request to public URL but not private

I have a rest API deployed as a service in the same environment as my main service - i can send requests to it over the public network using requests, but if i try to use the private network link I get the following trace: https://pastebin.com/1a2Tkrt1
Pastebin
2024-01-30 17:09:52,994 django.request ERROR Internal Server Err...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
41 Replies
Percy
Percy5mo ago
Project ID: 6ec4e69f-153c-42b1-8399-d4fbd6db04fb
meaniebeanie22
meaniebeanie225mo ago
6ec4e69f-153c-42b1-8399-d4fbd6db04fb
Brody
Brody5mo ago
what kind of app is the app you're trying to make a request to?
meaniebeanie22
meaniebeanie225mo ago
I have a flask-restful API that is being requested by a django app
Brody
Brody5mo ago
what's your current start command for the flask app
meaniebeanie22
meaniebeanie225mo ago
running off a dockerfile
CMD /venv/bin/waitress-serve --port=$PORT --call weasyprint_rest:app
CMD /venv/bin/waitress-serve --port=$PORT --call weasyprint_rest:app
Brody
Brody5mo ago
try changing it to
CMD /venv/bin/waitress-serve --listen=*:$PORT --call weasyprint_rest:app
CMD /venv/bin/waitress-serve --listen=*:$PORT --call weasyprint_rest:app
meaniebeanie22
meaniebeanie225mo ago
Pastebin
2024-01-30 17:28:19,228 django.request ERROR Internal Server Err...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
meaniebeanie22
meaniebeanie225mo ago
tl;dr looks the same
Brody
Brody5mo ago
show me the logs of the flask service, but use this https://bookmarklets.up.railway.app/log-downloader/
meaniebeanie22
meaniebeanie225mo ago
weasyprint_rest is flask api tkd-manager is django main app
Brody
Brody5mo ago
I see what's wrong this time do you have a PORT variable set in your flask service variables? if not, set one
meaniebeanie22
meaniebeanie225mo ago
import os
from .env import is_debug_mode
from .app import app

if __name__ == '__main__':
app().run(debug=is_debug_mode(), port=os.getenv("PORT", default="5000"))
import os
from .env import is_debug_mode
from .app import app

if __name__ == '__main__':
app().run(debug=is_debug_mode(), port=os.getenv("PORT", default="5000"))
This is what i use to run it, so it just uses the one railway randomly generates - do i just pull a number from anywhere and use that?
Brody
Brody5mo ago
if you like 5000 then set 5000 as a PORT variable
meaniebeanie22
meaniebeanie225mo ago
twas the default in the railway provided flask template, don't really care
Brody
Brody5mo ago
alrighty go ahead and set that
meaniebeanie22
meaniebeanie225mo ago
so just set environment var 'PORT' to '5000'?
Brody
Brody5mo ago
a service variable
meaniebeanie22
meaniebeanie225mo ago
what's a service variable?
meaniebeanie22
meaniebeanie225mo ago
this?
No description
Brody
Brody5mo ago
the variables you set on a service yep
meaniebeanie22
meaniebeanie225mo ago
can you explain why while i wait for the redeploy please?
Brody
Brody5mo ago
this is an internal network, so you have to specify the port in the url for the request the same way you have to when developing locally and since you have set that PORT variable, now internally your service runs an http server and listens on port 5000, unlike the public url that is https and port 443
meaniebeanie22
meaniebeanie225mo ago
ah ok
requests.exceptions.ConnectionError: HTTPConnectionPool(host='weasyprint-rest.railway.internal', port=80): Max retries exceeded with url: /api/v1.0/health (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f47029b3680>: Failed to establish a new connection: [Errno 111] Connection refused'))
requests.exceptions.ConnectionError: HTTPConnectionPool(host='weasyprint-rest.railway.internal', port=80): Max retries exceeded with url: /api/v1.0/health (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f47029b3680>: Failed to establish a new connection: [Errno 111] Connection refused'))
looks the same to me although it still thinks port 80 for some reason
Brody
Brody5mo ago
right but you have yet to specify port 5000 in your request url
meaniebeanie22
meaniebeanie225mo ago
just add :5000 to the end of the url?
Brody
Brody5mo ago
yep, the same way you would when running locally you can think of the services in the private network as computers on the same network, no firewalls no proxys, no nothing, just domains for your convenience
meaniebeanie22
meaniebeanie225mo ago
cheers!
Brody
Brody5mo ago
all works?
meaniebeanie22
meaniebeanie225mo ago
mhm
Brody
Brody5mo ago
awesome
meaniebeanie22
meaniebeanie225mo ago
well the pdfs that can only be fetched as a response from a POST request exist and have contents
Brody
Brody5mo ago
I don't see any issues there
Krøn
Krøn4mo ago
@Brody im having the same issue, im getting the private url from a env variable i put
No description
Krøn
Krøn4mo ago
requests.exceptions.ConnectionError: HTTPConnectionPool(host='userservice.railway.internal', port=8001): Max retries exceeded with url: /docs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fdeb4cd33d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
requests.exceptions.ConnectionError: HTTPConnectionPool(host='userservice.railway.internal', port=8001): Max retries exceeded with url: /docs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fdeb4cd33d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
Brody
Brody4mo ago
I thought you had a thread for this?
Krøn
Krøn4mo ago
the other one was for a different issue
Brody
Brody4mo ago
okay it was another recent thread with connection refused https://discord.com/channels/713503345364697088/1206265894016131172/1206283628762370139
Krøn
Krøn4mo ago
should i move there? seems to be an uno server something something, mine is a fastapi app
Brody
Brody4mo ago
same exact concept applies
Krøn
Krøn4mo ago
alright thank you