Facebook JS API can't logout

I have a localhost website and script with FB.logout(). After some actions, it fails to log me out and I see next error message in console:

Refused to display 'https://www.facebook.com/home.php' in a frame because it set 'X-Frame-  Options' to 'DENY'.

I searched all StackOverflow and didn't find any working solution. Network inspector shows cancelled near home.php query. So I understand that the script tries to load the Facebook homepage in a frame, but it can't because it is prohibited. So how can I fix it? Why doesn't logout() work for me?

My code

// Facebook Basic Example

window.fbAsyncInit = function() {
    appId      : '579651098766258',
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML

  FB.Event.subscribe('auth.authResponseChange', function(response) {
    if (response.status === 'connected') {
    } else if (response.status === 'not_authorized') {
    } else {

 var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
 if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 ref.parentNode.insertBefore(js, ref);

function testAPI() {
  FB.api('/me', function(res) {
      FB.logout(); // <-- ERROR
    }, 2000);


This solution worked for me:

  1. Go to Settings tab in your facebook application and in Basic tab scrolldown to +Add Platform
  2. Click on +Add Platform and choose Website
  3. Add your url of your website (for me, was the same url added on Advanced tab on Redirect URIs)
  4. Save changes and test again.

Also I made a youtube video to solve this problem: https://www.youtube.com/watch?v=7CNpLgwa0-c

I had to set the "App Domains" field in the Settings tab within the Facebook's App control panel in order for it to work:

I'm not sure how your HTML looks like, but for me this worked on my logout button:

onclick="javascript:FB.logout(function() { window.location.reload() }); return false;"

I hope this will help someone out, at least this fixed my problem.

Update by 2019 May 2nd:

1) The https now is enforced, so you must use https://localhost. http will no longer be available.

2) You need to whitelist your localhost by going to Settings > Basic > Add Plat form and choose "Website"

Update for 2018

From the App Dashboard, under the Facebook Login product, click on Quickstart and follow the instructions. The Logout API call should start working!

Note: I selected WWW and entered http://localhost:5757/ in the Site URL.

I have found that with www.example.com I get this error and without the www (example.com) there is no error...

Need Your Help

Return a value of '1' a referenced cell is empty


In Excel, I need to return a value of 1 if a referenced cell is empty