Getting error: Origin null is not allowed by Access-Control-Allow-Origin.

I have a small WebStorm project with one html file, one javascript file, and one python file.  In the javascript file, I use jquery to do an AJAX request to local Apache server asking to execute the python file as a CGI file.  This works perfectly when I enter "http://localhost/~<my user name>/TestAjax/ajaxhtml.html" in Google Chrome or Firefox.  The python CGI file works fine.  However, if i enter "file:///Users/<my user name>/Sites/TestAjax/ajaxhtml.html" in Chrome or Firefox, the html file is rendered and the javascript is executed but the AJAX request to access the python CGI file fails.  If i then open the Google Web Inspector, I see this message: "XMLHttpRequest cannot load file:///Users/<my user name>/Sites/TestAjax/ Origin null is not allowed by Access-Control-Allow-Origin."  If I try to  debug from the WebStorm project, the browser always uses the "file://" location.  I've tried to use the "localhost" url's in my scripts but haven't been able to get it to work.  When I try to use the "localhost" location in the Run/Debug configuration, I get an error message: "Error: Cannot fine debug file."

Anyone run into this and know how to work around it?


WebStorm 5.0, Chrome 26.0.1410.28 beta, Firefox 19.0.2, Mac OS X 10.8.2

Comment actions Permalink

Hi Thomas,

Define Deployment entry (Settings | Deployment) and mark it as Default for this project -- you will be able to use proper URL (not file:/// ).You may then use Remote JavaScript debug instead of Local (not sure though).

I do not know for sure where your project is located, but I guess that deployment entry of "In Place" type should be OK here (a guess based on your URLs/file paths)

Some links to read (they are a bit old, but still actual):

Alternatively (not recommended though -- it's rather workaround): if you still want to use Chrome as is, start it with the following option:


In WebStorm browsers are configured in "Preferences | Web Browsers"
Comment actions Permalink

Wow.  Andriy, your 2,282nd post was a life-saver.  Thank you so much.  The links you gave me to the older docs were *really* helpful.  I set it up as Remote and everything worked fine on the first try and I learned a lot in the process.  Thanks again.

Comment actions Permalink

Hi Andriy,

It looks like the --allow-file-access-from-files does not work. Could you please give more details?
I tried setting it in the command line settings but  it still does not work. I've attached a screenshot.

Thank you,Screen Shot 2013-04-03 at 10.36.07 AM.png

Comment actions Permalink

Try also specifying

flag -- maybe you need both of them (sorry, I'm not using Chrome myself for developing, so not sure).

In any case: make sure that no Chrome browser is running at that time, otherwise old (already running) instance most likely will be used instead (which did not had those options when launched).

Comment actions Permalink

Great! thanks Andriy,
The solution turns out to be to close all chrome browsers and start the live edit. I didnt need to use --disable-web-security flag.
Another life saver from you. I was struggling with this since morning.
Thank you very much!

Comment actions Permalink

Same local files / Chrome problem here. And this worked perfectly for me:

Great product so far !


Please sign in to leave a comment.