PyCharm 2024.3 Help

Configure browsers

PyCharm is shipped with a predefined list of most popular browsers that you may install and launch automatically from the IDE during running, debugging, or previewing the output of an HTML file. PyCharm presumes that you install browsers according to a standard procedure and assigns each installation an alias which stands for the default path to the browser's executable file or macOS application. In addition to the browsers from the default list, you can configure custom browser installations.

PyCharm has a built-in web server that can be used to preview and debug your application in a web browser or IDE's built-in browser. This server is always running and does not require any manual configuration.

By default the built-in server port is set to the default PyCharm port 63342 through which PyCharm accepts connections from services. To change this default value, open the Settings dialog (Ctrl+Alt+S) , go to Build, Execution, Deployment | Debugger, and in the Built-in Server specify any other value starting from 1024.

  1. Press Ctrl+Alt+S to open settings and then select Tools | Web Browsers and Preview.

  2. The Web Browsers and Preview page that opens shows the browsers from the predefined list and the previously configured custom browser installations, if any. For each browser, PyCharm shows its name, the family to which it belongs, and the path to the browser's executable file/macOS application or the predefined alias that stands for this path.

  3. To activate a browser, select the checkbox next to its name. The browser will be added to the context menu of the Open in Browser menu item and its icon will be displayed in the browser icons popup.

    If the browser was installed according to a standard installation procedure, most likely the alias in the Path field points at the right location. If it does not, click the Browse button and select the actual path in the dialog that opens.

When you select View | Open in Browser, or press Alt+F2, or invoke the browser icons bar, the available browsers are shown in the order in which they are listed on the Web Browsers and Preview page. To change the order of browsers in the list, use the Up and Down buttons.

Configure custom browsers

  1. Press Ctrl+Alt+S to open settings and then select Tools | Web Browsers and Preview.

  2. Click the Add button on the toolbar and in the new row specify the browser name, family, and the path to its executable or macOS application.

Use a custom profile

For Firefox and browsers of the Chrome family, you can use a custom profile.

  • On the Web Browsers and Preview page, select the browser and click on the toolbar. Depending on the family of the selected browser, the Firefox Settings or Chrome Settings dialog opens.

    • For Firefox, specify the path to the required profiles.ini file and choose the profile to use from the list. Learn more at Firefox browser profile.

    • For Chrome, select the Use custom user data directory checkbox and specify the location of your user data directory in the PyCharm settings.

    • To launch a browser of the Chrome family with additional options, click on the toolbar and type the required keys in the Command Line Options field of the Chrome Settings dialog that opens. Learn more about Chrome command-line options by opening chrome://flags in Chrome.

Remove browsers from the list

  • Select the required browser and click on the toolbar. Note that only custom browsers can be removed.

Choose the default PyCharm browser

When you want to preview your application output in the browser by choosing View | Open in Browser from the main menu or Open in Browser from the context menu of a file, you need to choose the browser to open the preview in. You can use a specific browser from the context menu or choose Default Browser.

PyCharm also opens the PyCharm default browser to render external resources.

  1. Press Ctrl+Alt+S to open settings and then select Tools | Web Browsers and Preview.

  2. From the Default Browser list, choose the browser to use by default for previewing pages.

    • To use the default operating system browser, choose System default.

    • To use the browser on top of the list, choose First listed. Change the order or browsers using the Up and Down icons on the toolbar.

    • To use another browser as default, choose Custom path and specify the location of the executable file of the required browser. Type the path manually or use Browse the Browse button, if necessary.

Configure the browser icons popup

By default, the browser icons popup appears only in HTML files. In XML files, the popup by default does not show up to help you read and edit your code without distraction.

  • To have the popup displayed or hidden in HTML or XML files, go to the Tools | Web Browsers and Preview page of settings  Ctrl+Alt+S and use the For HTML files and For XML files checkboxes in the Show browser popup in the editor area.

  • If you configure the popup to be hidden in HTML or XML files, you can preview files of the corresponding type using the View | Open in Browser command from the main menu or the Open in Browser command from the context menu of the file.

Configure automatic reload of HTML pages

By default, after you open an HTML file in the browser or in the built-in preview, PyCharm automatically reloads the page every time this HTML file (or any linked JavaScript or Style Sheet file) is saved manually or automatically, refer to Save and revert changes.

You can change the default behavior to reload the page as you type so the changes to the HTML or related file immediately appear in the browser or in the built-in preview.

  1. Go to the Tools | Web Browsers and Preview page of settings  Ctrl+Alt+S. Alternatively, click Configure in the Got it tooltip.

  2. In the Reload behavior area, from the Reload page in browser and Reload page in built-in preview lists, select the actions that will trigger automatic reload of pages in web browsers and in the built-in preview. By default, On Save is selected.

    • Select On Change to reload pages as you update the corresponding HTML file or linked files.

    • Select Disabled to suppress automatic upload.

For more information, refer to Configure automatic reload.

Last modified: 08 October 2024