Connecting upstash redis to my django prject

Ok, as far as getting your Upstash Redis to work with your deployed app, the problem is above. hosts is configured to talk to 127.0.0.1 (which is commonly referred to as localhost). But your Upstash Redis instance is not on localhost.

Run fly redis list to find the name of your Redis instance, e.g. mine was aged-forest-2800. Then do fly redis status aged-forest-2800, replacing aged-forest-2800 for your own instance name. This should show you a line that looks like:

Private URL    = redis://default:2bad98a37c2e43d687455fc7bdf16d89@fly-aged-forest-2800.upstash.io:6379

I’ve very briefly scanned these docs, so take what follows with a grain of salt (e.g. it may be insecure, amongst other things), but it looks like you want your config to be along the lines of:

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": ["redis://default:2bad98a37c2e43d687455fc7bdf16d89@fly-aged-forest-2800.upstash.io:6379"],
        },
    },
}

but using the private URL for your own Redis.

WARNING: I don’t recommend putting secrets like this private URL in a settings file that you’re going to commit to git. Instead, the recommendation is to load these settings from an environment variable. I’d suggest taking a look at the docs on secrets.