prisma: Cannot run cli behind proxy

I’ve been trying to follow the getting started tutorial for prisma and have been stuck on the very beginning.

When I try to run the init command:

npx prisma init

I get the following error:

Downloading Prisma engines for windows [                    ] 0%
Error: request to https://binaries.prisma.sh/master/76857c35ba1e1764dd5473656ecbbb2f739e1822/windows/query-engine.exe.gz.sha256 failed, reason: connect ECONNREFUSED 13.227.120.121:443

I am currently working under a company proxy which is what I think might be the problem, however I have the environment variables as well as npm configs set correctly and have no idea why this is happening or how to fix it.

I am using a windows machine, as you can tell from the error message. I have tried installing globally but get the same result.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

Update I got it working… had to use

ENV PRISMA_BINARIES_MIRROR http://prisma-builds.s3-eu-west-1.amazonaws.com

For the mirror to work under a company proxy. https does not work under a company proxy even though I can wget to the direct https:// site. Hope theres a real fix for this soon.

Also I did have http_proxy & https_proxy set but still had no luck until I added the above

Final working dockerfile:

FROM node:12.16.3-slim

RUN mkdir -p /var/app
WORKDIR /var/app
ADD . /var/app

ENV http_proxy http://{company_url}:8080
ENV https_proxy https://{company_url}:8080
ENV NODE_ENV production

RUN rm -r node_modules
RUN rm -r .next

RUN apt-get -qy update && apt-get -qy install openssl

ENV PRISMA_BINARIES_MIRROR http://prisma-builds.s3-eu-west-1.amazonaws.com
RUN npm install
RUN npx prisma generate --schema ./server/prisma/schema.prisma
RUN npm run build

EXPOSE 8080
CMD ["npm", "run", "start"]

Hope this helps others 😄

using prisma generate in a docker image

in case someone still gets this issue, here what I tried :

  • appending ?sslmode=disable to db url
  • DEBUG='*' proxy -p 8180 && HTTP_PROXY=http://localhost:8180/ HTTPS_PROXY=https://localhost:8180/ prisma generate
  • NODE_TLS_REJECT_UNAUTHORIZED=0

nothing worked until finding this thread with ENV PRISMA_BINARIES_MIRROR http://prisma-builds.s3-eu-west-1.amazonaws.com

Ahh, you are all switching from our https endpoints to http without SSL. That might indeed explain why your local networks do not block requests (although blocking requests to hostnames behind SSL is pretty questionable).

Is binaries.prisma.sh a new domain ?

It is an actually load balanced and globally distributed hostname that serves the same files as prisma-builds.s3-eu-west-1.amazonaws.com.

@pantharshit00 Thank you for the quick response.

I had already tried setting the environment variables before, to no avail. Tried again to make sure, but same result.

I can manually download the binaries, so I don’t think my proxy is blocking access to the url.

I managed to workaround the cli downloads by manually downloading the binaries and extracting them to a binaries folder within my project and pointing to them with the environment variables raise to my attention in #1333.

This, however, is not really maintainable, but works for now. When the current alpha version gets released the PRISMA_BINARIES_MIRROR environment variable probably will be the way to go for me.

Hi again,

Can you please all try the latest alpha version? We had this fix merged #2540 which might fix the issue for you all

It worked for me! Thank you!

I’ve spent this whole day trying to get this problem fixed, I tired setting up a node proxy server to forward requests to https://binaries.prisma.sh, but am still stuck with this error…

Error: request to https://binaries.prisma.sh/master/2fb8f444d9cdf7c0beee7b041194b42d7a9ce1e6/debian-openssl-1.1.x/query-engine.gz.sha256 failed, reason: connect ECONNREFUSED 13.226.18.126:443

Would really not like to rewrite all my code without prisma since that would be way too time consuming, any chance a fix like the one described by @ethernal might be coming soon. That way people under corporate proxies won’t run into issues downloading binaries.

The problem is not the CDN links but that, as in my case, your proxy requires authentication. I have not dug into the code yet but WHAT is downloading the binaries? It’s not npm (i have it configured for proxy), if it’s a fetch from a JS/binary file then this would explain things.

One solution (possible?) would be to make an npm packages from binaries and load them as dependencies or just invoke npm/yarn to install them - that way we could have it all working as expected.

The other way around would be need to implement proxy with authentication support for whatever piece of software is downloading the binaries. What do you think @janpio @pantharshit00 ?

PS. it would be good to add the available ENV variables for biaries location in Prisma documentation.

Here it is:

  prisma {
  prisma   argv: [
  prisma     'C:\\Program Files\\nodejs\\node.exe',
  prisma     'C:\\Users\\joaomanke\\Desktop\\prisma\\node_modules\\@prisma\\cli\\build\\index.js',
  prisma     'init'
  prisma   ]
  prisma } +0ms
  prisma Environment variables not loaded +6ms
  getos { platform: 'win32', libssl: undefined } +0ms
  download { fileExists: false, cachedFile: null } +0ms
  download { needsToBeDownloaded: true } +0ms
  download { fileExists: false, cachedFile: null } +2ms
  download { needsToBeDownloaded: true } +0ms
  download { fileExists: false, cachedFile: null } +1ms
  download { needsToBeDownloaded: true } +1ms
  download Downloading https://binaries.prisma.sh/master/2fb8f444d9cdf7c0beee7b041194b42d7a9ce1e6/windows/migration-engine.exe.gz to C:\Users\joaomanke\Desktop\prisma\node_modules\@prisma\cli\migration-engine-windows.exe +2ms
> Downloading Prisma engines for windows [                    ] 0%  download Downloading zip +3ms
  download Downloading https://binaries.prisma.sh/master/2fb8f444d9cdf7c0beee7b041194b42d7a9ce1e6/windows/query-engine.exe.gz to C:\Users\joaomanke\Desktop\prisma\node_modules\@prisma\cli\query-engine-windows.exe +18ms
  download Downloading zip +2ms
  download Downloading https://binaries.prisma.sh/master/2fb8f444d9cdf7c0beee7b041194b42d7a9ce1e6/windows/introspection-engine.exe.gz to C:\Users\joaomanke\Desktop\prisma\node_modules\@prisma\cli\introspection-engine-windows.exe +2ms
  download Downloading zip +1ms
Error: FetchError: request to https://binaries.prisma.sh/master/2fb8f444d9cdf7c0beee7b041194b42d7a9ce1e6/windows/introspection-engine.exe.gz.sha256 failed, reason: connect ECONNREFUSED 13.227.120.27:443
    at ClientRequest.<anonymous> (C:\Users\joaomanke\Desktop\prisma\node_modules\@prisma\cli\build\index.js:2:505664)
    at ClientRequest.emit (events.js:315:20)
    at TLSSocket.socketErrorListener (_http_client.js:432:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:84:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

I realize that on the 8th line it says prisma Environment variables not loaded +6ms

Just in case this is relevant, here are my npm configs:

; cli configs
metrics-registry = // Company mirror repo
scope = ""
user-agent = "npm/6.14.4 node/v13.12.0 win32 x64"

; userconfig C:\Users\joaomanke\.npmrc
registry = // Company mirror repo

; builtin config undefined
prefix = "C:\\Users\\joaomanke\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\joaomanke\Desktop\prisma
; HOME = C:\Users\joaomanke
; "npm config ls -l" to show all defaults.

And my Environment Variables (the relevant ones at least) :

HTTP_PROXY= // Proxy with user and pwd -> http://user:password@proxy:port
HTTPS_PROXY= // Proxy with user and pwd -> http://user:password@proxy:port
DEBUG=*

Sorry for the late reply,

Can you please set the env var DEBUG=* (set DEBUG=* on Windows) and post the full output here? Maybe that gives us some insight.

Will do, later today when I get to work I’ll post it here.