39

I recently found out that I can disable Chrome "web security" using a command line argument, making JavaScript development easier. The issue is that I can't seem to run more than one "instance" of Chrome at a time. If I chrome.exe --disable-web-security while Chrome is alread running, it just opens a new window within the running instance and ignores my command line arguments. I can close Chrome completely and relaunch it with the above command line argument, but then all my windows will be running without web security, which is a bad thing for general browser usage.

So to summarize the question: Is it possible to start an instance of Chrome with the --disable-web-security flag while a normal Chrome instance is running?


Note: I suspect the answer may lay within the Chrome command line switches, but there are just... so many...

5 Answers 5

44

I found a similar question on Ask Ubuntu. Apparently you can tell Chrome to start a new session by passing it a new user data directory. This means I can now run this command:

chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security

And a new Chrome window opens with web security disabled. Yay!


Note: This means that window drag & drop won't work between these two windows.

8
  • 1
    You can tell Chrome to start a new session by passing it a new user data directory. Yup; in fact, it does this with most switches; an “instance” is Chrome run with a unique set of arguments (in any order). It may not behave exactly the same now, but user-data-dir at a minimum will still trigger a new instance. Window drag & drop won't work between these two windows. Nope; as far as Chrome is concerned, they are from two different browsers/apps. Also be wary of handlers: running an .htm file or bookmark will open in an instance with the args specified in the type registration.
    – Synetech
    Commented May 13, 2013 at 3:35
  • Is there a way to do this in Mac OS X?
    – aug
    Commented Jul 22, 2014 at 17:39
  • 1
    @aug: I can't test this, but try (from the terminal): open -a /Applications/Chrome.app --user-data-dir="/tmp/chrome_dev_session" --disable-web-security. I'm assuming here that OSX has a "/tmp/" directory, you can change the path if it doesn't.
    – Hubro
    Commented Jul 22, 2014 at 17:48
  • 1
    I'm getting this you are using an unsupported command-line flag disable-web-security Commented Dec 9, 2014 at 9:08
  • 1
    @CoryMawhorter This is already in an answer below
    – Hubro
    Commented Aug 27, 2015 at 4:44
6

Close all the opened windows in the Chrome browser. If multiple windows are opened, close everything separately. Then you can open Chrome using the following code in "RUN":

chrome.exe --allow-file-access-from-files --disable-web-security
4

For Mac:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/tmp/chrome_dev_session" --disable-web-security 

Replace with your particular path to Chrome if necessary.

3

Responding to @aug and @hubro's comments, you can use the open command's -n flag to open a new instance of an app via Mac OS X's Terminal:

open -n -a /Applications/Chrome.app

You can add any flags that you want to use (like --disable-web-security) onto the end of that command.

5
  • This doesnt seem to create a new instance. Because when I try it in the old instance (with security not disabled) I can do cors
    – tobbe
    Commented Aug 20, 2014 at 11:40
  • Huh, you're right! The man page of the open command does indicate that the -n flag is for opening a new instance of an application, but it seems like Chrome & Chromium have some kind of logic preventing multiple instances of the application from being opened. The command works as is for Safari, for example. Commented Sep 2, 2014 at 19:45
  • Since this answer is incorrect, can you delete it?
    – Noel Yap
    Commented Oct 20, 2015 at 21:11
  • 1
    I don't have a mac, but I heard that it works if you include the --user-data-dir option also: open -n -a /Applications/Chrome.app --user-data-dir="/tmp/chrome_dev_session" --disable-web-security. Please give that a try. Commented Jan 25, 2016 at 1:09
  • 1
    @SamWatkins's approach worked for me in macOS Sierra, but only after adding the --args flag and opening the Chrome executable (not the Chrome.app container); so: open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_session_2" --disable-web-security
    – Bungle
    Commented Sep 29, 2016 at 6:36
1

You can use some fork of Chrome as a second browser, like Iron or Dragon. Maybe a portable instance of Chrome would work too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .