ERROR: Invalid value "undefined" for header "Content-Length" (Youtube Node)

When trying to upload a file to youtube using the youtube node I get the following error:


TypeError: Invalid value "undefined" for header "Content-Length"
    at ClientRequest.setHeader (node:_http_outgoing:655:3)
    at new ClientRequest (node:_http_client:286:14)
    at Object.request (node:https:378:10)
    at RedirectableRequest._performRequest (C:\Users\Julian\AppData\Roaming\npm\node_modules\n8n\node_modules\follow-redirects\index.js:296:24)
    at new RedirectableRequest (C:\Users\Julian\AppData\Roaming\npm\node_modules\n8n\node_modules\follow-redirects\index.js:69:8)
    at Object.request (C:\Users\Julian\AppData\Roaming\npm\node_modules\n8n\node_modules\follow-redirects\index.js:535:14)
    at dispatchHttpRequest (C:\Users\Julian\AppData\Roaming\npm\node_modules\n8n\node_modules\axios\lib\adapters\http.js:202:25)
    at new Promise (<anonymous>)
    at httpAdapter (C:\Users\Julian\AppData\Roaming\npm\node_modules\n8n\node_modules\axios\lib\adapters\http.js:46:10)

I read somewhere that the issue was resolved for someone by adding a .env file to the root dir with “N8N_DEFAULT_BINARY_DATA_MODE=filesystem” in it. However, this hasn’t solved the issue. Is there a way for me to check if this is active btw?

Can anyone help me?

My Workflow

Information on my n8n setup

  • **n8n version:latest
  • **Database (default: SQLite): default
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • **Running n8n via npm
  • **Operating system: Windows

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I figured out that somehow the env file is not being loaded successfully. When I manually start n8n with N8N_DEFAULT_BINARY_DATA_MODE=filesystem the node does seem to do something.

Can anyone tell me why n8n is not loading my .env file correctly? The file is placed in the same directory as package.json

Hi @Julian_Strengers, there are a couple of ways you can check whether an environment variable is set. The easiest would probably be to simply execute a Set node with an expression of {{ $env["N8N_DEFAULT_BINARY_DATA_MODE"] }}:

Can anyone tell me why n8n is not loading my .env file correctly? The file is placed in the same directory as package.json

My best guess is that’s because the directory isn’t the working dir for n8n. When using the npm version of n8n I have to place a .env file in the directory I am calling n8n start from for the variables to be processed instead of the package.json directory.

In general, I prefer using docker compose instead for a more straightforward configuration when using n8n. This way I can just list all the environment variables alongside with any other settings (like n8n version to use, restart policy, open ports etc) in a single docker-compose.yml file:

services:
  n8n:
    image: n8nio/n8n:1.20.0
    restart: unless-stopped
    environment:
      - QUEUE_HEALTH_CHECK_ACTIVE=true
      - N8N_DIAGNOSTICS_ENABLED=false
      - N8N_VERSION_NOTIFICATIONS_ENABLED=false
      - N8N_TEMPLATES_ENABLED=false
      - EXTERNAL_FRONTEND_HOOKS_URLS=
      - N8N_DIAGNOSTICS_CONFIG_FRONTEND=
      - N8N_DIAGNOSTICS_CONFIG_BACKEND=
    ports:
      - 5678:5678
    volumes:
      - ./n8n_data:/home/node/.n8n

Perhaps you want to give this approach a go as well instead of using npm?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.