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
Percy10mo ago
Project ID: 6ec4e69f-153c-42b1-8399-d4fbd6db04fb
meaniebeanie22
meaniebeanie22OP10mo ago
6ec4e69f-153c-42b1-8399-d4fbd6db04fb
Brody
Brody10mo ago
what kind of app is the app you're trying to make a request to?
meaniebeanie22
meaniebeanie22OP10mo ago
I have a flask-restful API that is being requested by a django app
Brody
Brody10mo ago
what's your current start command for the flask app
meaniebeanie22
meaniebeanie22OP10mo 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
Brody10mo 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
meaniebeanie22OP10mo 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
meaniebeanie22OP10mo ago
tl;dr looks the same
Brody
Brody10mo ago
show me the logs of the flask service, but use this https://bookmarklets.up.railway.app/log-downloader/
meaniebeanie22
meaniebeanie22OP10mo ago
weasyprint_rest is flask api tkd-manager is django main app
Brody
Brody10mo 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
meaniebeanie22OP10mo 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
Brody10mo ago
if you like 5000 then set 5000 as a PORT variable
meaniebeanie22
meaniebeanie22OP10mo ago
twas the default in the railway provided flask template, don't really care
Brody
Brody10mo ago
alrighty go ahead and set that
meaniebeanie22
meaniebeanie22OP10mo ago
so just set environment var 'PORT' to '5000'?
Brody
Brody10mo ago
a service variable
meaniebeanie22
meaniebeanie22OP10mo ago
what's a service variable?
meaniebeanie22
meaniebeanie22OP10mo ago
this?
No description
Brody
Brody10mo ago
the variables you set on a service yep
meaniebeanie22
meaniebeanie22OP10mo ago
can you explain why while i wait for the redeploy please?
Brody
Brody10mo 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
meaniebeanie22OP10mo 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
Brody10mo ago
right but you have yet to specify port 5000 in your request url
meaniebeanie22
meaniebeanie22OP10mo ago
just add :5000 to the end of the url?
Brody
Brody10mo 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
meaniebeanie22OP10mo ago
cheers!
Brody
Brody10mo ago
all works?
meaniebeanie22
meaniebeanie22OP10mo ago
mhm
Brody
Brody10mo ago
awesome
meaniebeanie22
meaniebeanie22OP10mo ago
well the pdfs that can only be fetched as a response from a POST request exist and have contents
Brody
Brody10mo ago
I don't see any issues there
Krøn
Krøn10mo ago
@Brody im having the same issue, im getting the private url from a env variable i put
No description
Krøn
Krøn10mo 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
Brody10mo ago
I thought you had a thread for this?
Krøn
Krøn10mo ago
the other one was for a different issue
Brody
Brody10mo ago
okay it was another recent thread with connection refused https://discord.com/channels/713503345364697088/1206265894016131172/1206283628762370139
Krøn
Krøn10mo ago
should i move there? seems to be an uno server something something, mine is a fastapi app
Brody
Brody10mo ago
same exact concept applies
Krøn
Krøn10mo ago
alright thank you
Want results from more Discord servers?
Add your server