DisallowedHost at /
Invalid HTTP_HOST header: ‘globalsjconsultant.com ’. You may need to add ‘globalsjconsultant.com ’ to ALLOWED_HOSTS.
I wanted to add a custom domain by updating nameservers. I have added allowed host in settings.py but it is not working. Later I added allowed hosts in vercel environment variables also but that also did not work. Can you tell what is the issue?
setings.py
from decouple import config, Csv
ALLOWED_HOSTS = config(‘ALLOWED_HOSTS’, default=‘127.0.0.1’, cast=Csv())
.env file
ALLOWED_HOSTS=127.0.0.1,.vercel.app,globalsjconsultant.com ,www.globalsjconsultant.com
Deployment URL: https://globalsjconsultant-k3qoc71sr-muhammad-safdars-projects-58d3387f.vercel.app/
Custom Domain: https://globalsjconsultant.com/
Environment (local, preview, production): production
Project Framework: django



pawlean
(Pauline P. Narvas)
October 8, 2024, 12:01pm
2
Hi, @globalsjconsultant ! Welcome to the Vercel Community
Heads up: I edited the title of your post to make it more searchable for other community members who may be going through a similar issue.
Let me try and help out here!
What does your settings.py
file look like? Make sure that it explicitly includes your custom domain. Something like:
from decouple import config, Csv
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='127.0.0.1,globalsjconsultant.com,www.globalsjconsultant.com', cast=Csv())
It might also be help to understand the rest of your project structure e.g. vercel.json
and wsgi.py
contents.
If the issue persists after trying this, please check the following:
Verify that your custom domain’s DNS settings are correctly pointing to Vercel’s nameservers.
Make sure that the custom domain is properly added and verified in your Vercel project settings.
Check Vercel’s deployment logs for any errors related to environment variables or Django configuration.
Let us know how you get on!
This was so frustrating. How it is possible that we deploy on vercel but can’t assign a custom domain? My allowed hosts were configured correctly. I didn’t receive any reply from support and community.
pawlean
(Pauline P. Narvas)
October 9, 2024, 11:15am
4
Totally hear your frustration
From my previous message:
And:
Would be helpful to dig a bit deeper here
1 Like
system
(system)
Closed
November 8, 2024, 11:15am
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.