R
Railway

✋|help

Yyori_390359/10/2023
I am using a Django REST framework. When I query the URL at 0.0.0.0:8000 I can get a response, but at the URL I get the page is not found error. How can I link the two?
Yyori_390359/10/2023
N/A
MMantisInABox9/10/2023
Is your app listening on Port 8000? If so, you will want to set an environment variable of PORT to 8000
Yyori_390359/10/2023
Thanks, that's what I already did
MMantisInABox9/10/2023
Okay, and it is still not working?
Yyori_390359/10/2023
Still not working. The end point works at: http://0.0.0.0:8000/join-codes/ but does not work at the domains.

At https://django-rest-starter-production-xxxx.up.railway.app/join-codes/ I return an empty [] get response where the above returns json data

Is this something I have to configure within Django?
* at the railway domain
MMantisInABox9/10/2023
Did you add the URL to your allowed hosts in your django settings.py file?
Yyori_390359/10/2023
I believe this adds all available hosts? ALLOWED_HOSTS = ["*"] That's what I have
MMantisInABox9/10/2023
Yeah, that should work for sure...
Yyori_390359/10/2023
Do I need to also perhaps add this to trusted origins?

ALLOWED_HOSTS = [""]

Comment out the following line and place your railway URL, and your production URL in the array.
CSRF_TRUSTED_ORIGINS = ["
"]
MMantisInABox9/10/2023
You might need to, especially if you are passing form data
Yyori_390359/10/2023
Hmmm, still not working. Maybe some sort of Django authentication thing
MMantisInABox9/10/2023
It's possible. Are you seeing any errors in your deploy logs?
Yyori_390359/10/2023
No, I'm not.

The endpoint is there because when I specify a different endpoint from the one I set up I get a page not found. However, when I try the Railway domain, I get the [] JSON endpoint data.

However, at 0.0.0.0:8000/endpoint, the data returns just fine
I get the empty [] JSON endpoint data from the Railway domain
Here is the response from the Railway URL: (200 succesful REST API response but no data returned)

Summary
URL: https://django-rest-starter-production-xxxx.up.railway.app/join-codes/
Status: 200
Source: Network
Address: xxxxxx

Request
:method: GET
:scheme: https
:authority: django-rest-starter-production-xxxx.up.railway.app
:path: /join-codes/
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,
/;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Cookie: stripe_mid=f83557e6-3a42-4594-bafb-3c24a3bfdd8e0150bd; stripe_sid=2e6be1d1-6830-491e-8805-b12f10c8f22daf9969; ajs_anonymous_id=e9a1b8cf-e0ce-4e0e-b88c-707c374f04ba; ajs_user_id=39160776-f724-4d9e-a4b8-cd23a2df7871; csrftoken=hyPsStxpwOdc4OnEOAxHudDFxaHwI6uH
Host: django-rest-starter-production-7b48.up.railway.app
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15

Response
:status: 200
Content-Length: 2
Content-Type: application/json
Cross-Origin-Opener-Policy: same-origin
Date: Sun, 10 Sep 2023 22:50:45 GMT
Referrer-Policy: same-origin
Server: railway
Vary: origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Here is the response from 0.0.0.0:8000/join-codes endpoint which returns also a successful response, but this time returns the actual data:

Summary
URL: http://0.0.0.0:8000/join-codes/
Status: 200 OK
Source: Network
Address: 127.0.0.1:8000

Request
GET /join-codes/ HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,
/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Host: 0.0.0.0:8000
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15

Response
HTTP/1.1 200 OK
Content-Length: 178
Content-Type: application/json
Cross-Origin-Opener-Policy: same-origin
Date: Sun, 10 Sep 2023 22:53:28 GMT
Referrer-Policy: same-origin
Server: WSGIServer/0.2 CPython/3.10.9
Vary: origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
MMantisInABox9/10/2023
Are you able to share your git repo?
Yyori_390359/10/2023
I would have to make another one because this is the company git
However, I noticed that the header size is much larger for 0.0.0.0 url, so maybe an authentication thing?
]
0.0.0.0:
Yyori_390359/10/2023
Yyori_390359/10/2023
Railway:
Yyori_390359/10/2023
Yyori_390359/10/2023
I am just using the Django Starter REST repo given by Railway
MMantisInABox9/10/2023
Is the API currently running on your local machine?
Yyori_390359/10/2023
yes
MMantisInABox9/10/2023
Is the service running on railway connected to the same database as the server running on your local machine?
Yyori_390359/10/2023
yes, but i'm not returning data from a database currently, just dummy test data in the python script
MMantisInABox9/10/2023
Then there is an issue with your python script somewhere. Because if it is dummy data, it should be returning.

Getting results off 0.0.0.0 is not necessarily a sign of it working, as that’s just a loop back to the server you have running on your local system. You may need to add some print statement to send to your deploy logs on railway to ensure everything is working as intended
Yyori_390359/10/2023
I figured out the issue! What was happening is I was not using a GET decorator for the Python method. While that method was working on local (because of following a tutorial), Django must require a decorator for security authentication from an external URL (just a guess). But that worked! Thank you so much for your help!!!

Looking for more? Join the community!

Recommended Posts
OpenSearch deploymentHi everyone. I require assistance with deploying an instance of OpenSearch since I get an error durUnable to connect with private networkHey guys, I'm a bit unsure on how to use the internal network. I have a .net api that has a privaterclone on railway to transfer data from one cloud to an other.Hello, I'm creating an app the requires to transfer data from one cloud storage (like onedrive to aBun 1.0 on railwayI am spinning up a simple bun app with 1 file in it. But for some reason all of my builds are failinSocket cannot be archivedWhen building the railway project I get a message saying that: /Users/x/Library/Application SupportBUN 1.0 + AstroHas anyone tried to deploy a Bun app yet? I am getting this error. ERROR: failed to solve: processDjango Railway admin consoleHi! I've had a really good time using Railway thus far, sea-change from setting up an EC2 instance Trouble sending emails via SMTPprojectId: `bb66f5c0-53f9-4e9f-b11f-5965f5d6ec74` serviceId: `b3029692-b78a-4487-bcb0-44e001afecb8` Cannot have a TCP proxy and a domainWhen trying to create a service with a proxy, I'm getting this error. Can I not have a TCP proxy serChange region for Postgres DatabaseHey ! Congratulations for the launch of deployment region ! Now, how can I migrate my db to another Connection Pooling or PgBouncer for Postgres Instances?Hello! Anyone know if the Railway Postgres instance has any sort of connection pooling or pgBouncer?webhook to rebuild serviceHi I have one project: Mongo, PayloadCMS + storage, Nextjs I want to trigger nextjs rebuild after aI paid 40 dollars in subscription fees but its still dont pay my debt for credits.deploy prisma/client not foundhey, when I deploy the prisma client in node_modules is not found because its not generating, I haveCan you explain how usage is estimatedI have an account with a hobby plan subscription, I have a discord bot running on it and a MySQL DB Trying to save a fileTrying to save a file in media/ where can i save files ? PermissionError: [Errno 13] Permission dHelp setup a monorepo - Angular / ExpressHi! Hope everyone is doing well :). I am trying to deploy my Angular application on railway, but it Nose.Js versionhow do i change itVolume creation prevents service from deployingHi! I'm trying to add a volume to a project, but when I attach it to the service, it stops being abldeploy bun 1.0 projectdoes anyone know if and how thats possible on railway currently?