PlatformIO IDE in VSCode can't connect to the Internet - blocked by Proxy

Hey there!

I’m struggeling a bit trying to get PlatformIO working behind my corporate proxy. VSCode grabs the Proxy-settings from the wpad-config in Windows (10) and asks me for credentials on startup. That way I was able to download PIO from the extension manager.
The first problem arose as VSCode was not able to download cpptools automatically, so i downloaded the *.vsix manually. Then I had to manually setup the virtual python environment.
PIO is working now but is blocked by the proxy. I can’t download libaries and if I want to create a new project the board drop-down menu stays empty (0 available). Setting the environment variables HTTP_PROXY and HTTPS_PROXY didn’t help.

Thanks for any help in advance!
Thomas

See docs Redirecting...

Yes, the PIO IDE Terminal shows the environment variables values after a restart if I query them like that.

I tried setting the variables with and without my credentials, both variants didn’t enable PIO IDE to connect to the internet.

Giving the proxy-settings to pip in a similar form --proxy="http://<username>:<password>@proxy.hs-karlsruhe.de" works to download python packages.

I tried to use the request-package in python like suggested on your link which resulted in an error:

requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘proxy.hs-karlsruhe.de’, port=8888): Max retries exceeded with url: http://example.org/ (Caused by ProxyError(‘Cannot connect to proxy.’, error(‘Tunnel connection failed: 403 Forbidden’,)))

EDIT: I fixed it
http://<username>:<password>@proxy.hs-karlsruhe.de:8888/
Environment variable has to be formated exactly that way. I never thought the last slash could be important…

So, could you provide the final instruction here? I would be thankful! We will create a separate page in FAQ and describe it.

To get the PIO IDE in VSCode on Windows 10 to connect to the internet through a proxy I had to set two environment variables for my user.

HTTP_PROXY: http://<username>:<password>@proxy.hs-karlsruhe.de:8888/
HTTPS_PROXY: http://<username>:<password>@proxy.hs-karlsruhe.de:8888/

Important for me (maybe obvious for someone with more knowledge :wink: ) was that

  • don’t include a domain
  • protocol in front of the username has to be http:// not https://
  • slash at the end is important
  • restart computer
2 Likes

Does VSCode use the same environment variables? Should we use one of these methods?

At the moment VSCode seems to grab the proxy-settings defined in my windows-settings. There I listed the path to a wpad.dat script that sets up the proxy. Everytime I start up VSCode I get a prompt to input my credentials (as shown in the VSCode-docs you linked). There it says the proxy is at port 8010 and not 8888. Port 8010 is the one defined on the wpad so I know VSCode is using that instead of the environment variables where i used 8888. Wierdly I get that exact same prompt a second time when the PIO Home Tab is loading in, altrough PIO doesn’t seem to use it.

If I delete the wpad-path in the windows-settings leaving the environment variables the only thing defining the proxy VSCode can’t connect to the internet anymore (can’t download extensions i.e.). Doing so will still result in PIO beeing able to connect to the internet…

Something else I tried was to set "http.proxyAuthorization" and "http.proxy" in the VSCode settings.json, but I could not get a working connection that way for neither VSCode nor the PIO IDE.

In the VSCode settings.json it says

 // The value to send as the 'Proxy-Authorization' header for every network request.
 "http.proxyAuthorization": null

 // The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables.
 "http.proxy": ""

I think the problem is, that PIO needs to have the credentials/authentification in the environmental variables itself while VSCode just wants the address in the variable and the credentials seperatly.

I think we can use this the same file and automatically propagate all system environment variables for Python.

How did you set them? Sorry, I’m not a Windows user.

Who did create this file? What is inside this file? Could you provide an example?

I’m not sure that this a good idea :frowning:

In the windows settings is something like this


there I listed the address to the setup-script provided by out University IT-department. If “automatically detect settings” is activated it should be found automatically by the computer in the intranet (to my understanding), but that doesn’t work on some computers so you have to input it manually.
The file should be downloadable from anywhere if you want to take a look (wpad.dat).

Well, that’s the same way Firefox handles it (get a prompt there too every time I start it). And it feels better than having you credentials in your environmental variables in plain text.

Btw., maybe you have read that already, maybe not… Extension proxy support · Issue #12588 · microsoft/vscode · GitHub

Hello community,

I wonder if there is any news on this topic to securely set proxy credentials for platformio (maybe directly through pio, as using platformio through vscode might not be the only use case on a single machine).

For me, settings within vscode dont work (beside the fact that vscode itself works smoothly without additional settings as it uses windows settings).

But either option mentioned in FAQ: It’s truly not a valid option to store credentials as plain text, especially inside system variables where every program / virus / whatever has access to!

Please: Add a functionality to pio settings to securely store those credentials (encrypted). Or make it possible to use windows credentials. PlatformIO is a beautiful development tool, but this issue makes it difficult to “legally” use it in a corporate context

See Redirecting...

What is the link to download .vsix manually? It is not obvious from the releases page.

Found these sites, but would prefer an official PlatformIO site

vsixHub at

Or the Microsoft Market place, which does not seem like it has the vsix file just shows how to load it on VSCode

So I tried the download at VSIXhub

And it needed this

cpptools-linux.vsix
cpptools-linux.vsix

and everything seemed to install.

Have another look… it is there on the Microsoft marketplace :wink:

1 Like

Thanks for the visual. Nice to have the official download.

I got it installed on cloud Gitpod, but presently it is not very active, I think I have to install the core as well. This is nothing to do with Platformio probably more to do with how gitpod/theia uses extensions.

1 Like

Yeah, you need the core for the real functionality, the extension just provides the glue that integrates PIO into VSCode. Normally you’d restart VSCode after installing the extension, and the extension would then manage the install of PIO core, but I don’t know how/if you can do the same with gitpod/theia. Edit: Oh, I see you posted about Gitpod and PIO the other week, so yeah, it looks like you should be able to get it all working. or are at least pretty close! :wink:

Presently it looks like just installing the core is enough for the cloud platform.


python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"

The two files needed to install the vscode extension seem to just mess things up. Once again that is probably more to do with Gitpod than anything with platformIO

The core works fine and does all that I want it to do.

“Except this nagging little pio remote run t-upload t-nobuild thing I have been trying to understand/hoping will work soon”

1 Like

There is also docs here Redirecting...

1 Like

Setting proxy in the preference resolves the problem. And, ‘Proxy Strict SSL’ should be OFF

This proxy problem took me also almost 2 days now.
The problem in the end was, that my password includes some special chars like # and @, and this was the reason why the installation failed.

After replacing them with the UTF8-Codes, it worked.

So for example if your password is
Pw#12345
replace # by %23
and set this into the http_proxy string:

http://username:Pw%2312345@proxyIP:8080

Finally this works for me. Please, add this hint to the documentation you linked below. I think lots of people could run into this problem.

However it is not understandable for me, how one can implement such an user-unfriendly input mask.
Why not a input box for username, one for password, with automatic decoding of special chars.

And in general, I think it’s a no-go to store a password unencrypted in any ini file.
This really is not a professional solution. I hope the developers take care for a better solution in future.
I would prefer to get a message box requesting username and pw each time, instead of storing my credentials