Lewis981
Database URL different and not working
I'm struggling to set up my Django project, it can't use the DATABSE_URL value the way it normally would. I get this error:
Traceback (most recent call last):
File "/opt/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 275, in ensure_connection
self.connect()
File "/opt/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(args, **kwargs)
File "/opt/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 256, in connect
self.connection = self.get_new_connection(conn_params)
File "/opt/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(args, kwargs)
File "/opt/venv/lib/python3.10/site-packages/django/db/backends/postgresql/base.py", line 277, in get_new_connection
connection = self.Database.connect(conn_params)
File "/opt/venv/lib/python3.10/site-packages/psycopg2/init.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not translate host name "postgres.railway.internal" to address: Name or service not known
I am using the following code to connect to the DB:
db_url = os.environ["DATABASE_URL"]
DATABASES = {"default": dj_database_url.parse(db_url, engine='django.db.backends.postgresql')}
This works great in another project I've deployed. But when I investigate the DATABASE_URL value in that project, it's different. Rather than using "postgres.railway.internal" it uses "roundhouse.proxy.rlwy.net"
Is this a recent change to database config on railway side, or am I just doing something wrong?
16 replies
Deployment Failed during build process
I have a celery worker that has run and built fine for the last several months. After pushing a small change today, the build began to fail. I am 100% sure that the code pushed didn't cause this, and I haven't changed anything regarding the build command or setup process. What could be causing this failure?
ERROR: failed to solve: process "/bin/bash -ol pipefail -c nix-env -if .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix && nix-collect-garbage -d" did not complete successfully: exit code: 1
5 replies
Website Under Attack
This morning I woke up to over 7000 emails from my Django server of Disallowed Host errors. My app is correctly rejecting the requests, which are all coming from a single IP address and are also trying to access my site at the IP level rather than the domain. Here is an example: Invalid HTTP_HOST header: '35.230.16.13:6868'. You may need to add '35.230.16.13' to ALLOWED_HOSTS.
DisallowedHost at /druid/index.html
Invalid HTTP_HOST header: '35.230.16.13:6868'. You may need to add '35.230.16.13' to ALLOWED_HOSTS.
Request Method: GET
Request URL: http://35.230.16.13:6868/druid/index.html
Exception Value: Invalid HTTP_HOST header: '35.230.16.13:6868'. You may need to add '35.230.16.13' to ALLOWED_HOSTS.
Request information:
USER: [unable to retrieve the current user]
GET: No GET data
POST: No POST data
FILES: No FILES data
COOKIES: No cookie data
META:
HTTP_ACCEPT = '/'
HTTP_ACCEPT_ENCODING = 'gzip'
HTTP_ACCEPT_LANGUAGE = 'en'
HTTP_CONNECTION = 'close'
HTTP_HOST = '35.230.16.13:6868'
HTTP_USER_AGENT = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0 Information Security Team InfraSec Scanner'
PATH_INFO = '/druid/index.html'
QUERY_STRING = ''
RAW_URI = '/druid/index.html'
REMOTE_ADDR = '34.87.32.244'
REMOTE_PORT = '49742'
REQUEST_METHOD = 'GET'
SCRIPT_NAME = ''
SERVER_NAME = '0.0.0.0'
SERVER_PORT = '6868'
SERVER_PROTOCOL = 'HTTP/1.1'
SERVER_SOFTWARE = 'gunicorn/20.1.0'
The HTTP_USER_AGENT and the REMOTE_ADDR are the same in all 7000 requests. The path it is attempting to access changes, and it sometimes includes POST data with usernames and passwords at an attempt to login with default IDs (like username="admin" password="123321"). This is eating through my email allotment with Amazon SES, but I don't want to turn off error notifications. The site is set up wiht Cloudflare nameservers, but as the bot is hitting the IP it seems to be bypassing the firewalls. Am I able to block an IP at the server level through railway?
16 replies
Cron Jobs and Celery Beat
I'm using celery to run a task daily at 1:30pm. The task takes about 15 minutes. the celery container is still running for the other 23 and a half hours that it does nothing, so I set up a cron job to launch it half an hour before the task starts. The result I expected was that the container would start up, wait for it's command from celery beat, run the task, and shut down again. However, it skipped every time, and I can't even access the logs on the skip to see what the issue was. Am I doing something wrong here?
14 replies
Server Resource Usage Efficiency Help
My Django projects are normally relatively cheap, running low use websites. My latest project requires celery to run a task at 7am everyday - so I now have a Redis server, and two other services up pointing too my main repository, one running a celery worker, and the other running the celery beats schedule to trigger celery task execution's. Setting this up has quadrupled the estimated cost for hosting my project. Is there a best practice I'm not implementing here? I intended to add the worker and beat to my default Django server; but it seems Railway doesn't support this. Any tips or suggestions will be appreciated.
12 replies
Postgres Migration
I am using a Postgres DB and the migration was successful. I did not hardcode URLS and am simply configuring them through enviroment variables. Despite this fact, I get this message:
The following service is still connected to this plugin through variables. Update these variables to avoid data loss.
Please note if these services are still writing data after the migration, this data will be lost when you remove the legacy service.
What do I need to update before deleting the old DB?
37 replies
Domain A Record Assistance
Based on my browsing of others issues, I am assuming I will need to do something with Cloudflare, but I am not sure what.
I use domain.com for my domain. With railway, I have two custom domains set up with CNAME's added to my DNS records with domain.com. One is the root domain (example.com) and another is a subdomain with the www prefix (www.example.com).
When checking my sie on https://intodns.com I get several nameserver errors. After inspecting my DNS records, I believe it is due to domain.com automatically configuring a wildcard (@) A record pointing to an IP address in their personal server. As Railway uses dynamic IP's, I can't simply change the IP address that the A record points to, as I'd have to do this everytime I deploy a new version of my site.
What am I misunderstanding here? How do I properly handle this?
6 replies
'Failed to fetch deployments" Message
I am working on deploying a Django site to my railway account. I have two other sites up and running successfully. When I deploy, everything looks good, but I don't get a link. The deploy logs show nothing out of the ordinary, and neither do the build logs. When I attempt to do it in my terminal with the CLI, I get the following message: ======= Build Completed ======
🚨 Failed to fetch deployments
Anyone know what could be causing this?
Anyone know what could be causing this?
8 replies
Do I need SSL Certificates?
My app is up and running with Django. When I attempt to enable the secure SSL redirect setting in Django, my page displays as "unable to redirect properly" and breaks my app completely until I remove the setting. Any idea on what could be causing this? It is the first website I have deployed so I may be completely missing something as far as SSL requirements go.
4 replies
AWS S3 Integration
Hello! I am brand new to Railway and just deployed my first app. I will be using AWS S3 in order to save/serve static files. Are their any Railway specifics I should know about when it comes to content delivery? Anything specific I should add to my Django project?
Specifically, I am wondering about the CORS configuration and if anyone has any idea what the proper CORS parameters are.
project id is puny-wrench
12 replies