WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  1. www.mysite.com/wp-admin/admin-ajax.php returns error 404 when logged out.
  2. www.mysite.com/wp-admin/admin-ajax.php loads a blank page with 0 when LOGGED IN. This is the proper behavior as per Wordpress.org AJAX
  3. There are NO rewrite rules on my .htaccess files.

    # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

    # END WordPress

  4. Also tried turning off all plugins and still can't access admin-ajax.php when logged out.

Anyone have an idea why wp-admin/admin-ajax.php returns 404 when NOT LOGGED IN? Normally when you access www.mysite.com/wp-admin/admin-ajax.php it should return a blank page with 0.

share|improve this question
are you accessing those URLs directly? they're not meant for that – moraleida Aug 5 '14 at 3:07
I'm not accessing them directly but use it for ajax request. I use it with the following hooks and call them on my javascript ajax request. add_action('wp_ajax_nopriv_my_action', 'my_action'); add_action('wp_ajax_my_action', 'my_action'); But for some reason it only works when logged in. If I'm logged out it returns error 404. @moraleida – SandoMarco Aug 5 '14 at 3:11

Make sure you set your

define( 'WP_DEBUG', false );

Else you may get 404. In my case I had that problem, when I inherited some project where there was many notices, and PHP warnings. This may be connected with the Ajax problem I had at that time.

The temporary solution was to set debugging to false in my case.

share|improve this answer
This may be better suited as a comment than answer. I haven't run across a single scenario where having debugging turned on has resulted in 404 or erroneous functionality. Do you have anything to backup your claim that keeping debugging on 404s admin-ajax.php? – Howdy_McGee May 20 at 18:08
It happens to be the case on my end today. Lucky me, that we can provide the helpful answer candidates without much digging into deep. When having lot of troubles, anything that may help is welcome. I strongly believe, that for someone this will mean some saved hours. BTW, I fully understand your point of view and agree @HowdyMcGee. – prosti May 20 at 18:12
Also if I get the chance later to understand this problem deeper, I would improve my answer. – prosti May 20 at 18:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.