Next.js Discord

Discord Forum

ERR_SSL_WRONG_VERSION_NUMBER for GET Requests behind an https load balancer

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
Hi everyone, I am currently running v13.5.5-canary.7 and all server side GET requests running in standalone behind an https load balancer results in the following error:

export const GET = async (req: Request) => { 
    ...
    return new Response(res, {
    status: 200,
    headers: {
      'content-type': 'application/xml',
      'cache-control': 's-maxage=31556952',
    },
  });
}

TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:13220:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: [Error: 185CCA705E3E0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:354:] 
{
    library: 'SSL routines',
    reason: 'wrong version number',
    code: 'ERR_SSL_WRONG_VERSION_NUMBER'
}


I had previously seen this same error with next/images however that was resolved in a v13.5.x build. Is anyone else facing this issue?

38 Replies

what is the node version you are running
ssl error normally only happens when you are running old node
make sure you are on node 18.x
Sun bearOP
This also happening for v13.5.4 and v13.5.3
I am running node:20-alpine
I believe that maps to 20.8.0
im running newest node just fine. Its more likely you have not added the required libssl needed
make a codesandbox showing the same error. if you cannot, it is your container. alpine linux has extreme differences in configuration complexity for all types of runtimes and requires more knowledge to maintain.
Sun bearOP
I can find the exact error I see mentioned in an open nextJS issue but relating to next/image:

https://github.com/vercel/next.js/issues/56038#issuecomment-1736121768
potentially relating to this: https://github.com/vercel/next.js/pull/56226
Sun bearOP
I'm not entirely sure how to go about creating a codesandbox for a server running behind a proxy / load balancer. The endpoint is accessible locally, just not behind an https proxy / load balancer. When running this via GCP's Cloud Run, I have been seeing this error
That directly infers that it is your configuation. if it works locally/on vercel and doesnt behind some config you have done outside of nextjs, it is not a nextjs issue. If it is in fact the issue in the github issue linked, then that is the place to address it.

Feel free to leave the help request open but im just warning you that the chances of it being resolved here are slim from the current info
Sun bearOP
there isn't anything unique to my configuration. Its built via next build and packaged in a Docker image. I see some work had been done for https here: https://github.com/vercel/next.js/pull/55775/files theres potentially an issue with route handlers: https://nextjs.org/docs/app/building-your-application/routing/route-handlers
@Sun bear there isn't anything unique to my configuration. Its built via `next build` and packaged in a Docker image. I see some work had been done for https here: https://github.com/vercel/next.js/pull/55775/files theres potentially an issue with route handlers: https://nextjs.org/docs/app/building-your-application/routing/route-handlers
you are validating my point. if the issue is with the core code then github is the place to address it not here. I personally have the recent stable build autoscaling behind a kubernetes ingress proxy with zero issues which makes me lean towards it being your config, but the former message stands
Turkish Angora
I'm also having this issue right now
upstream image response failed for /_next/static/media/CallToActionBackground.6bf2a67e.png TypeError: fetch failed


library: 'SSL routines',
reason: 'wrong version number',
code: 'ERR_SSL_WRONG_VERSION_NUMBER'
Node 20.8.0 as well
Turkish Angora
@Sun bear it's also bricking my website completely, you can't access it at all when this error occurs
only solution is to do npm run build and redeploy it
it's really a massive burden this issue
Sun bearOP
@Turkish Angora yeah :/ fortunately for me its just one non critical endpoint so I still have my app in production with a todo to resolve it at a later date. I saw your posts in the github thread. Thanks for escalating it. Looks like some folks are having more luck with certain canary builds but Im just going to wait it out for now
Turkish Angora
Good news, the issue is now being tracked by maintainers
Turkish Angora
emphasis on might
That x-forwarded-* headers fix was linked to the issue @Sun bear
Turkish Angora
@Sun bear Try canary 16, it's too early to say but I think the issue is fixed with the revert drop ipc headers fix
Sun bearOP
Thanks! I am going to wait for the final 13.5.5 release to roll out but I appreciate the heads up. Makes sense that it has to do with the headers not propagating through
Turkish Angora
@Sun bear It’s finally out! 🙌🏾
Sun bearOP
nice, Ill try it out later today! Thanks
Sun bearOP
looks like my specific issue is still there with 13.5.5 :/
@Sun bear https://github.com/vercel/next.js/issues/56038#issuecomment-1758039701
Turkish Angora
you ran npm run build && npm run start again right?
Sun bearOP
yeah my setup is a bit different though, I use gcp http load balancers that inject headers to a gcp cloud run container running in http, It’s a bit of a black box with networking for me tbh but I think the problem is there
Netherland Dwarf
Did everyone get this solved? I'm having basically the same problem when using a custom server, and I see upstream image response failed for /layers.png TypeError: fetch failed in the logs
Netherland Dwarf
A few other notes:
* I'm using Node 20. Are people who are seeing this using Node 18 or Node 20?
* I'm hosting my app on Heroku
* The error I'm seeing mentions port 3000, but that is likely not the port it's running on Heroku, and I don't use port 3000 locally, either. Is there any setting that encourages things to run on port 3000? Here's a bit of that snippet of the error:
upstream image response failed for /MyLogoFileName.png TypeError: fetch failed
 at Object.fetch (node:internal/deps/undici/undici:11413:11)
 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
...
cause: Error: connect ECONNREFUSED 127.0.0.1:3000
2023-11-09T23:50:52.862837+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
 at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
 errno: -111,
 code: 'ECONNREFUSED',
 syscall: 'connect',
 address: '127.0.0.1',
 port: 3000
}