VSCode Python Jedi client: couldn't create connection to Server

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
2 min

banner

# VSCode Python Jedi client: couldn't create connection to Server

To solve the VSCode "Python Jedi client: couldn't create connection to Server" error, set the python.languageServer setting to Pylance in your settings.json config file.

This is necessary because, in more recent versions of VS Code, Pylance is the default language server.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: You can also press F1 to open the Command Palette.
  1. Type user settings json.

  2. Click on Preferences: Open User Settings (JSON)

preferences open user settings

The command directly opens your settings.json file.

  1. Add the following line to your settings.json file.
settings.json
"python.languageServer": "Pylance"

set python language server to pylance in settings json

Once you add the line, restart VS Code and make sure you have the Pylance extension installed.

  1. Click on Extensions in the left sidebar.
  • You can also open the Extensions menu by pressing:
    • Ctrl + Shift + X on Windows or Linux.
    • Command + Shift + X on macOS.
  1. Type Pylance.

install pylance extension

  1. Click on the Install button.

If that doesn't work, you can try to set your python.languageServer to "Default".

settings.json
"python.languageServer": "Default"

# Setting your Python Language Server in your local settings.json

You can also set your Python Language Server in your local settings.json file.

  1. In the root directory of your project, create a .vscode folder.

  2. Create a settings.json file in the .vscode folder.

  3. Add the following code to your settings.json file.

.vscode/settings.json
{ "python.languageServer": "Pylance" }

set python language server in your local settings json file

The settings that you've added to your local settings.json file overwrite any global configuration and only apply to the current project.

If that doesn't work, you can try to set your python.languageServer to "Default".

settings.json
"python.languageServer": "Default"

# Try to uninstall and reinstall the Pylance extension

If the error persists, try to uninstall the Pylance extension and then reinstall it.

  1. Click on the Extensions button and search for Pylance.
  2. Click on the Uninstall button.

uninstall pylance extension

  1. Once you've uninstalled the extension, click on the Install button to reinstall it.

  2. Restart VS Code.

# Deleting the Pylance extension files manually

If that didn't work either, try to delete the Pylance extension files manually.

  1. Check out my article on how to find the VS Code extensions location.
  2. Once you find the extension folder, search for pylance and delete all folders whose name contains "pylance".
  3. Reinstall the Pylance extension as shown in the previous subheading.
  4. Restart VS Code.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.