36

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...

40

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.

  • 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 May 13 '13 at 3:35
  • Is there a way to do this in Mac OS X? – aug Jul 22 '14 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 Jul 22 '14 at 17:48
  • 1
    I'm getting this you are using an unsupported command-line flag disable-web-security – CodyBugstein Dec 9 '14 at 9:08
  • 1
    @CoryMawhorter This is already in an answer below – Hubro Aug 27 '15 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
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.

  • 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 Aug 20 '14 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. – arielkirkwood Sep 2 '14 at 19:45
  • Since this answer is incorrect, can you delete it? – November Yankee Oct 20 '15 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. – Sam Watkins Jan 25 '16 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 Sep 29 '16 at 6:36
3

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.

0

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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