Page Not Found (404) for /accounts/login/ on Railway (Works Fine Locally
supercool27
FREEOP

a year ago

I have deployed a Django app to Railway, and while everything works fine in my local development server, the /accounts/login/ page throws a 404 error on the live server.

πŸ”— Live URL:

https://server-production-7653.up.railway.app/accounts/login

My Project Structure:

pgsql

CopyEdit

project-root/ β”œβ”€β”€ mysite/ β”‚ └── urls.py β”œβ”€β”€ accounts/ β”‚ β”œβ”€β”€ urls.py β”‚ └── views.py β”œβ”€β”€ templates/ β”‚ └── accounts/ β”‚ └── login.html

πŸ“‚ Code Snapshots:

mysite/urls.py:

python

CopyEdit

from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('accounts/', include('accounts.urls')), ]

accounts/urls.py:

python

CopyEdit

from django.urls import path from django.contrib.auth import views as auth_views urlpatterns = [ path('login/', auth_views.LoginView.as_view(template_name='accounts/login.html'), name='login'), ]

settings.py:

python

CopyEdit

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ BASE_DIR / "templates" ], 'APP_DIRS': True, ... } ]

πŸ” What I’ve Tried:

  • Confirmed the templates/accounts/login.html exists and renders locally.
  • Verified all files are pushed to GitHub.
  • Confirmed Railway is deploying the latest commit.
  • Tried accessing /accounts/ and /accounts/login/ β€” both give 404.
  • No errors during deployment, and /admin/ works fine.

❗ Suspicions:

  • Template not being picked up in production?
  • Git may not have tracked the templates/ folder earlier (already forced git add -f templates/).
  • Could Railway have cached an old build?

πŸ†˜ Request:

Could anyone help me debug what I might be missing or doing wrong? Any tips to ensure the app correctly routes /accounts/login/ in production?

Thanks in advance!

$10 Bounty

4 Replies

idiegea21
HOBBY

a year ago

Your /accounts/login/ page works locally but gives a 404 on Railway likely because the templates/accounts/login.html file wasn't included in your Git repo or wasn't deployed correctly.

Make sure that login.html is actually tracked and pushed

git add -f templates/accounts/login.html

git commit -m "Add login template"

git push

Then you come to railway and clear your build cache and then you redeploy.

if it still fails, check your railway logs and drop the error logs for better debugging.


sim
FREE

a year ago

I opened your url and it shows this

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:

admin/
The current path, accounts/login, didn’t match any of these.

That means only the /admin route is set up

Share how and where you are defining your routes



supercool27
FREEOP

a year ago

https://hrmdjango-production.up.railway.app/accounts/login/ i have successfully setup my first page with django. if anybody need it or help from me to host i can. Thank you for giving support.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...