a year ago
Anyone who has ever faced the similar issues, what are the usual causes of this? I am getting the server error 500 whenever I try to access my admin or other valid URLs. Note that: I haven't configured any databases yet.
15 Replies
a year ago
41c59dc8-07dc-421d-8a27-e17cf0d0bcd7
a year ago
i'd recommend setting debug to true so that django will tell you what is wrong
a year ago
okay will try
a year ago
yep getting the error that I expected:
OperationalError at /adminzurro/login/
connection to server at "127.0.0.1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
Request Method: POST
Request URL: http://azurrodjangoprod-production.up.railway.app/adminzurro/login/?next=/adminzurro/
Django Version: 5.0.7
Exception Type: OperationalError
Exception Value:
connection to server at "127.0.0.1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
Exception Location: /opt/venv/lib/python3.12/site-packages/psycopg2/init.py, line 122, in connect
Raised during: django.contrib.admin.sites.login
Python Executable: /opt/venv/bin/python
This is very likely because of the database config, right?
a year ago
yes, 5432 is Postgres, likely means you are not using the proper environment variables in code to connect to the database on railway
a year ago
I have a question tho, I am rn using my local PG database in the deployed code. I was using Heroku for my last deploy and for price concerns I shifted to railway.
After creating a new postgres database in railway, will I be able to migrate my heroku db here?
a year ago
yep, just pgdump the old database and pgrestore to the railway database, there's many many online guides for that!
a year ago
can you give me any such docs that I can refer to?
a year ago
sorry, I don't have any on hand, but they'd be a quick web search away!
a year ago
cool!
a year ago
hi can you check out this error that I am getting while connecting my railway postgres db to my local django project which I will deploy later:
RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': could not translate host name "postgres.railway.internal" to address: No such host is known.
a year ago
this is what I am using in the settings.py code:
Database settings
from decouple import config
DATABASES = {
'default': djdatabaseurl.parse(config('DATABASE_URL'))
}
a year ago
oh nvm, got it done. Was not using the public url. Thanks btw, my entire django code is deployed now along with the db.
a year ago
awesome glad to hear that?
a year ago
!s
Status changed to Solved brody • about 1 year ago