The first time I wired up Facebook Login on my website, I was met with a confusing little error instead of the nice login popup I expected. Somewhere in the browser console (or right inside the login window) was a message complaining about an unknown host domain coming from the Facebook JavaScript SDK.
If you’re seeing the same thing, don’t worry — you haven’t broken anything. This is one of the most common hiccups when you first set up Facebook Login, and it takes about two minutes to fix once you know where to look. Let me walk you through it.
What this error actually means
The Facebook JavaScript SDK (often shortened to “JSSDK”) is the little script that powers the “Continue with Facebook” button and other Facebook features on your site. Before Facebook lets that script do anything, it checks one thing: “Do I recognize the website this is running on?”
Facebook keeps a list of domains that each app is allowed to run on. If your website’s domain isn’t on that list, Facebook refuses to cooperate and throws the “unknown host domain” error. In plain English:
Your website is asking Facebook to log a user in, but Facebook has never been told that your website is allowed to use this app — so it stops and complains.
It’s a security feature, not a bug. Facebook doesn’t want random websites borrowing your app, so it only trusts the domains you’ve explicitly approved.
Why it happens
There are a few everyday reasons your domain isn’t on the list yet:
- You just created the app and never added your website to it.
- You moved from a test domain (like
localhost) to your real domain, but only added the old one. - Your site is served from a slightly different domain than you registered — for example
www.yoursite.comversusyoursite.com, orhttp://versushttps://.
In every case the fix is the same: tell Facebook about your domain.
How to fix it
Here’s the exact path I take. You’ll be logged into Facebook’s developer dashboard and adding your website URL to a specific settings field.
Step 1: Open your app in the Facebook developer dashboard
Log in to your Facebook account, then go to developers.facebook.com/apps. You’ll see a list of the apps connected to your account. Click into the app you’re using for login.
Step 2: Go to Facebook Login for Business → Settings
In the left-hand sidebar, find Facebook Login for Business and click Settings underneath it.
If you set up the older “Facebook Login” product instead, look for Facebook Login → Settings — the field we need lives in the same place.
Step 3: Add your website to “Allowed Domains for the JavaScript SDK”
On the Settings page, scroll down until you find the field labelled “Allowed Domains for the JavaScript SDK.” This is the list Facebook checks against — and right now your domain isn’t on it.
Type your full website URL into that field, for example:
https://www.yoursite.com
A couple of things that tripped me up the first time:
- Match it exactly. If your site loads at
https://www.yoursite.com, don’t enterhttps://yoursite.com. Thewww(and thehttps) have to match what’s actually in the browser’s address bar. - If users reach your site at both
yoursite.comandwww.yoursite.com, add both.
Step 4: Save and test
Scroll to the bottom and click Save changes. Then go back to your website, refresh the page (a hard refresh — ⌘+Shift+R on Mac or Ctrl+Shift+R on Windows — clears any cached scripts), and try the login again.
That’s it. In almost every case, the error is gone and the Facebook login popup appears like it should.
Still seeing the error? A quick checklist
If it didn’t work on the first try, run through these — one of them is usually the culprit:
- The domain doesn’t match. This is the number one cause. Double-check
wwwvs no-wwwandhttpvshttps. - You added a path or trailing slash. Use the bare domain (
https://www.yoursite.com), not a specific page likehttps://www.yoursite.com/login. - Caching. Your browser may be holding on to the old SDK script. Try a hard refresh, or test in a private/incognito window.
- Wrong app. If you have more than one Facebook app, make sure the App ID in your website’s code matches the app you just edited.
- Changes need a moment. Occasionally Facebook takes a minute to propagate the new setting. Give it a short wait and try again.
Wrapping up
The “unknown host domain” error looks intimidating, but it’s really just Facebook saying “I don’t recognize this website yet.” Once you add your domain to Allowed Domains for the JavaScript SDK, Facebook trusts your site and the login flow works as expected.
If you got here while setting up a login or chat integration and you’d rather not wrestle with Facebook’s settings at all, that’s exactly the kind of thing we help with at Respond Helper — get in touch and we’ll get you connected.