Flask subdomains + render?

i have gotten subdomains to work locally by editing the hosts file but i dont know how i could do this in render?

from flask import Flask

app = Flask(__name__)

# Define a route for the subdomain
@app.route('/', subdomain='sub')
def subdomain_home():
    return 'Hello from the subdomain!'

# Define a route for the main domain
def main_home():
    return 'Hello from the main domain!'

if __name__ == '__main__':

like i tried deploying this but the / domain works but the subdomain doesnt

This site can’t provide a secure connection

sub.domain.onrender.com uses an unsupported protocol.

i get this

i know that domain.onrender is already a sub domain but i think we can have sub sub domains and that the problem is with needing to edit a hosts file or something?

or would i have to make a new project and then with my domain registrar make sub.domain.com point to the domain of the new project?


Second-level subdomains on your services default server-name.onrender.com domain won’t work.

You’d need to use your own custom domain: https://docs.render.com/custom-domains


hi, maybe i dont understand right but, i tried subdomain in flask didnt work so i used to custom domain and connected example.com and sub.example .com but sub.example.com just goes to the default service cuz when i put sub.service.onrender .com it wont verify i think and either way it gives ssl error, does that mean i cant use flask subdomain and i would need to make a new render service and connect my sub.example . com to that service? this would technically work i just wanted to use subdomain so if you know any way pls let me know! thanks

and for some reason the main domain and sub domain i connected say certificate pending unlike my services with no sub domains, anyways if i make for sub.example.com cname to sub.service.onrender.com will it even verify? and if yes will it give the ssl error?
im sorry im just new to this so im not sure

i cant post many embeds cuz of the limit

without sub it works fine but adding sub it gives an error and you said something about custom domains i tried but maybe i just dont understand correctly i just connected my domain and when i go to sub.mydomain.com it gives the same error, so i tried verifying the subdomain itself but that just redirects to the base service page

The screenshot shows you’re still trying to use a second-level subdomain on an onrender.com domain. That will not work as noted previously.

Please can you use share examples rather than mydomain.com and example.com.


these both work and give this is the main domain, but when i go to sub they both give an unsupported protocol error

Let’s forget about the onrender.com address, as it doesn’t support second-level subdomains, as said above.

So let’s break down any.is-a.dev

is-a.dev is your root domain.

any.is-a.dev is your subdomain.

If you want another level of subdomain, e.g. second.any.is-a.dev. You would need to add that as a custom domain to your service, and set a CNAME record for second.any to any-w1a3.onrender.com.



from what i understand, is this what you mean?? or should the cname for sub.any be sub.any-w1a3? also both say certificate issued idk why it didnt show but after reloading it showed

if i did do it right it still does:

i have been trying many things but idk i cant figure it out


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.