[GH-ISSUE #3223] SyntaxError: Unexpected token '<', "<html> <h"... is not valid JSON #2073

Closed
opened 2026-02-22 18:28:02 -05:00 by yindo · 5 comments
Owner

Originally created by @Turkalypse on GitHub (Feb 15, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3223

I installed AnythingLLM on Ubuntu VPS, connected it to a domain name and made it HTTP to HTTPS.

I select any service and in the settings and API section I get the following errors:

1- Failed to load resource: the server responded with a status of 500 (Internal Server Error)
2- Error: Internal Server Error
at index.js:67:45151
at async a (index.js:307:25464)
3- POST https://x.me/api/system/update-env 502 (Bad Gateway)
4- SyntaxError: Unexpected token '<', "<html>
<h"... is not valid JSON

Image

Originally created by @Turkalypse on GitHub (Feb 15, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3223 I installed AnythingLLM on Ubuntu VPS, connected it to a domain name and made it HTTP to HTTPS. I select any service and in the settings and API section I get the following errors: 1- Failed to load resource: the server responded with a status of 500 (Internal Server Error) 2- Error: Internal Server Error at index.js:67:45151 at async a (index.js:307:25464) 3- POST https://x.me/api/system/update-env 502 (Bad Gateway) 4- SyntaxError: Unexpected token '<', "<html> <h"... is not valid JSON ![Image](https://github.com/user-attachments/assets/f22ffe13-f27e-44e9-9199-e92b08a83195)
yindo closed this issue 2026-02-22 18:28:02 -05:00
Author
Owner

@Turkalypse commented on GitHub (Feb 15, 2025):

I use port 3001 with reverse proxy (Nginx)

@Turkalypse commented on GitHub (Feb 15, 2025): I use port 3001 with reverse proxy (Nginx)
Author
Owner

@Turkalypse commented on GitHub (Feb 15, 2025):

I made a few edits in nginx.conf and default files. When checking the API URLs in the error with Curl, the errors persist even though '200 OK'.

Like:

root@IP:~# curl -I https://x.me/api/system/update-env
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sat, 15 Feb 2025 09:35:03 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1690
Connection: keep-alive
X-Powered-By: Express
Vary: Origin
ETag: W/"69a-tVI3FpcWE0szMcTWI5ao83oYY9Y"

@Turkalypse commented on GitHub (Feb 15, 2025): I made a few edits in nginx.conf and default files. When checking the API URLs in the error with Curl, the errors persist even though '200 OK'. Like: root@IP:~# curl -I https://x.me/api/system/update-env HTTP/1.1 200 OK Server: nginx/1.18.0 (Ubuntu) Date: Sat, 15 Feb 2025 09:35:03 GMT Content-Type: text/html; charset=utf-8 Content-Length: 1690 Connection: keep-alive X-Powered-By: Express Vary: Origin ETag: W/"69a-tVI3FpcWE0szMcTWI5ao83oYY9Y"
Author
Owner

@timothycarambat commented on GitHub (Feb 16, 2025):

You have set up NGINX likely incorrectly as a reverse proxy.
You are getting back the generic 502 error page from NGINX - that is why it is an HTML response, you are never reaching the actual app endpoint

server {
   # Enable websocket connections for agent protocol.
   location ~* ^/api/agent-invocation/(.*) {
      proxy_pass http://0.0.0.0:3001;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
   }

   listen 80;
   server_name [insert FQDN here];
   location / {
      # Prevent timeouts on long-running requests.
      proxy_connect_timeout       605;
      proxy_send_timeout          605;
      proxy_read_timeout          605;
      send_timeout                605;
      keepalive_timeout           605;

      # Enable readable HTTP Streaming for LLM streamed responses
      proxy_buffering off; 
      proxy_cache off;

      # Proxy your locally running service
      proxy_pass  http://0.0.0.0:3001;
    }
}
@timothycarambat commented on GitHub (Feb 16, 2025): You have set up NGINX likely incorrectly as a reverse proxy. You are getting back the generic 502 error page from NGINX - that is why it is an HTML response, you are never reaching the actual app endpoint ``` server { # Enable websocket connections for agent protocol. location ~* ^/api/agent-invocation/(.*) { proxy_pass http://0.0.0.0:3001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } listen 80; server_name [insert FQDN here]; location / { # Prevent timeouts on long-running requests. proxy_connect_timeout 605; proxy_send_timeout 605; proxy_read_timeout 605; send_timeout 605; keepalive_timeout 605; # Enable readable HTTP Streaming for LLM streamed responses proxy_buffering off; proxy_cache off; # Proxy your locally running service proxy_pass http://0.0.0.0:3001; } } ```
Author
Owner

@Turkalypse commented on GitHub (Feb 17, 2025):

You have set up NGINX likely incorrectly as a reverse proxy. You are getting back the generic 502 error page from NGINX - that is why it is an HTML response, you are never reaching the actual app endpoint

server {
   # Enable websocket connections for agent protocol.
   location ~* ^/api/agent-invocation/(.*) {
      proxy_pass http://0.0.0.0:3001;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
   }

   listen 80;
   server_name [insert FQDN here];
   location / {
      # Prevent timeouts on long-running requests.
      proxy_connect_timeout       605;
      proxy_send_timeout          605;
      proxy_read_timeout          605;
      send_timeout                605;
      keepalive_timeout           605;

      # Enable readable HTTP Streaming for LLM streamed responses
      proxy_buffering off; 
      proxy_cache off;

      # Proxy your locally running service
      proxy_pass  http://0.0.0.0:3001;
    }
}

When an error occurs on the API entry screen, the container closes and the following log is given:

[collector] info: [TikTokenTokenizer] Initialized new TikTokenTokenizer instance.
[collector] info: Collector hot directory and tmp storage wiped!
[collector] info: Document processor app listening on port 8888
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 778ms

Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client

Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db"

27 migrations found in prisma/migrations

No pending migrations to apply.
┌─────────────────────────────────────────────────────────┐
│ Update available 5.3.1 -> 6.3.1 │
│ │
│ This is a major update - please follow the guide at │
https://pris.ly/d/major-version-upgrade
│ │
│ Run the following to update │
│ npm i --save-dev prisma@latest │
│ npm i @prisma/client@latest │
└─────────────────────────────────────────────────────────┘
[backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data.
[backend] info: [TokenManager] Initialized new TokenManager instance for model: gpt-3.5-turbo
[backend] info: [TokenManager] Returning existing instance for model: gpt-3.5-turbo
[backend] info: [TELEMETRY ENABLED] Anonymous Telemetry enabled. Telemetry helps Mintplex Labs Inc improve AnythingLLM.
[backend] info: prisma:info Starting a sqlite pool with 5 connections.
[backend] info: [TELEMETRY SENT] {"event":"server_boot","distinctId":"56bdd1d4-f8ee-473e-847b-9dc2b8270ebc","properties":{"commit":"--","runtime":"docker"}}
[backend] info: [CommunicationKey] RSA key pair generated for signed payloads within AnythingLLM services.
[backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data.
[backend] info: Primary server in HTTP mode listening on port 3001
[backend] info: [BackgroundWorkerService] Feature is not enabled and will not be started.
[backend] info: [MetaGenerator] fetching custom meta tag settings...
[collector] info: [TikTokenTokenizer] Initialized new TikTokenTokenizer instance.
[collector] info: Collector hot directory and tmp storage wiped!
[collector] info: Document processor app listening on port 8888
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 715ms

Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client

Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db"

27 migrations found in prisma/migrations

No pending migrations to apply.
[backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data.
[backend] info: [TokenManager] Initialized new TokenManager instance for model: gpt-3.5-turbo
[backend] info: [TokenManager] Returning existing instance for model: gpt-3.5-turbo
[backend] info: [TELEMETRY ENABLED] Anonymous Telemetry enabled. Telemetry helps Mintplex Labs Inc improve AnythingLLM.
[backend] info: prisma:info Starting a sqlite pool with 5 connections.
[backend] info: [TELEMETRY SENT] {"event":"server_boot","distinctId":"56bdd1d4-f8ee-473e-847b-9dc2b8270ebc","properties":{"commit":"--","runtime":"docker"}}
[backend] info: [CommunicationKey] RSA key pair generated for signed payloads within AnythingLLM services.
[backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data.
[backend] info: Primary server in HTTP mode listening on port 3001
[backend] info: [BackgroundWorkerService] Feature is not enabled and will not be started.
[collector] info: [TikTokenTokenizer] Initialized new TikTokenTokenizer instance.
[collector] info: Collector hot directory and tmp storage wiped!
[collector] info: Document processor app listening on port 8888
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 700ms

Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client

Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db"

27 migrations found in prisma/migrations

No pending migrations to apply.
[backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data.
[backend] info: [TokenManager] Initialized new TokenManager instance for model: gpt-3.5-turbo
[backend] info: [TokenManager] Returning existing instance for model: gpt-3.5-turbo
[backend] info: [TELEMETRY ENABLED] Anonymous Telemetry enabled. Telemetry helps Mintplex Labs Inc improve AnythingLLM.
[backend] info: prisma:info Starting a sqlite pool with 5 connections.
[backend] info: [TELEMETRY SENT] {"event":"server_boot","distinctId":"56bdd1d4-f8ee-473e-847b-9dc2b8270ebc","properties":{"commit":"--","runtime":"docker"}}
[backend] info: [CommunicationKey] RSA key pair generated for signed payloads within AnythingLLM services.
[backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data.
[backend] info: Primary server in HTTP mode listening on port 3001
[backend] info: [BackgroundWorkerService] Feature is not enabled and will not be started.
[backend] info: [MetaGenerator] fetching custom meta tag settings...
[backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).
at new OpenAI (/app/server/node_modules/openai/index.js:53:19)
at openAiModels (/app/server/utils/helpers/customModels.js:84:18)
at getCustomModels (/app/server/utils/helpers/customModels.js:40:20)
at /app/server/endpoints/system.js:953:41
at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
at next (/app/server/node_modules/express/lib/router/route.js:149:13)
at /app/server/utils/middleware/multiUserProtected.js:60:7
at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
at next (/app/server/node_modules/express/lib/router/route.js:149:13)
at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5)
[backend] info: [GeminiLLM] Using cached models API response.
[backend] info: EmbeddingEngine changed from undefined to native - resetting undefined namespaces
[backend] info: [Event Logged] - workspace_vectors_reset
[backend] info: Resetting anythingllm managed vector namespaces for
/usr/local/bin/docker-entrypoint.sh: line 7: 111 Illegal instruction (core dumped) node /app/server/index.js


Also, where should I enter the code you provided? I entered it into the default. There is no .conf file for domain, and I haven't edited the nginx.conf.
/etc/nginx/sites-enabled/default content:

https://docs.google.com/document/d/1yZM_jrl5e_eDGCuqNk1ZCF9zSE_BTKExGaOnWO0ubyc/edit?usp=sharing

@Turkalypse commented on GitHub (Feb 17, 2025): > You have set up NGINX likely incorrectly as a reverse proxy. You are getting back the generic 502 error page from NGINX - that is why it is an HTML response, you are never reaching the actual app endpoint > > ``` > server { > # Enable websocket connections for agent protocol. > location ~* ^/api/agent-invocation/(.*) { > proxy_pass http://0.0.0.0:3001; > proxy_http_version 1.1; > proxy_set_header Upgrade $http_upgrade; > proxy_set_header Connection "Upgrade"; > } > > listen 80; > server_name [insert FQDN here]; > location / { > # Prevent timeouts on long-running requests. > proxy_connect_timeout 605; > proxy_send_timeout 605; > proxy_read_timeout 605; > send_timeout 605; > keepalive_timeout 605; > > # Enable readable HTTP Streaming for LLM streamed responses > proxy_buffering off; > proxy_cache off; > > # Proxy your locally running service > proxy_pass http://0.0.0.0:3001; > } > } > ``` When an error occurs on the API entry screen, the container closes and the following log is given: [collector] info: [TikTokenTokenizer] Initialized new TikTokenTokenizer instance. [collector] info: Collector hot directory and tmp storage wiped! [collector] info: Document processor app listening on port 8888 Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma ✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 778ms Start using Prisma Client in Node.js (See: https://pris.ly/d/client) import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate) import { PrismaClient } from '@prisma/client/edge' const prisma = new PrismaClient() See other ways of importing Prisma Client: http://pris.ly/d/importing-client Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db" 27 migrations found in prisma/migrations No pending migrations to apply. ┌─────────────────────────────────────────────────────────┐ │ Update available 5.3.1 -> 6.3.1 │ │ │ │ This is a major update - please follow the guide at │ │ https://pris.ly/d/major-version-upgrade │ │ │ │ Run the following to update │ │ npm i --save-dev prisma@latest │ │ npm i @prisma/client@latest │ └─────────────────────────────────────────────────────────┘ [backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data. [backend] info: [TokenManager] Initialized new TokenManager instance for model: gpt-3.5-turbo [backend] info: [TokenManager] Returning existing instance for model: gpt-3.5-turbo [backend] info: [TELEMETRY ENABLED] Anonymous Telemetry enabled. Telemetry helps Mintplex Labs Inc improve AnythingLLM. [backend] info: prisma:info Starting a sqlite pool with 5 connections. [backend] info: [TELEMETRY SENT] {"event":"server_boot","distinctId":"56bdd1d4-f8ee-473e-847b-9dc2b8270ebc","properties":{"commit":"--","runtime":"docker"}} [backend] info: [CommunicationKey] RSA key pair generated for signed payloads within AnythingLLM services. [backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data. [backend] info: Primary server in HTTP mode listening on port 3001 [backend] info: [BackgroundWorkerService] Feature is not enabled and will not be started. [backend] info: [MetaGenerator] fetching custom meta tag settings... [collector] info: [TikTokenTokenizer] Initialized new TikTokenTokenizer instance. [collector] info: Collector hot directory and tmp storage wiped! [collector] info: Document processor app listening on port 8888 Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma ✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 715ms Start using Prisma Client in Node.js (See: https://pris.ly/d/client) import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate) import { PrismaClient } from '@prisma/client/edge' const prisma = new PrismaClient() See other ways of importing Prisma Client: http://pris.ly/d/importing-client Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db" 27 migrations found in prisma/migrations No pending migrations to apply. [backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data. [backend] info: [TokenManager] Initialized new TokenManager instance for model: gpt-3.5-turbo [backend] info: [TokenManager] Returning existing instance for model: gpt-3.5-turbo [backend] info: [TELEMETRY ENABLED] Anonymous Telemetry enabled. Telemetry helps Mintplex Labs Inc improve AnythingLLM. [backend] info: prisma:info Starting a sqlite pool with 5 connections. [backend] info: [TELEMETRY SENT] {"event":"server_boot","distinctId":"56bdd1d4-f8ee-473e-847b-9dc2b8270ebc","properties":{"commit":"--","runtime":"docker"}} [backend] info: [CommunicationKey] RSA key pair generated for signed payloads within AnythingLLM services. [backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data. [backend] info: Primary server in HTTP mode listening on port 3001 [backend] info: [BackgroundWorkerService] Feature is not enabled and will not be started. [collector] info: [TikTokenTokenizer] Initialized new TikTokenTokenizer instance. [collector] info: Collector hot directory and tmp storage wiped! [collector] info: Document processor app listening on port 8888 Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma ✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 700ms Start using Prisma Client in Node.js (See: https://pris.ly/d/client) import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate) import { PrismaClient } from '@prisma/client/edge' const prisma = new PrismaClient() See other ways of importing Prisma Client: http://pris.ly/d/importing-client Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db" 27 migrations found in prisma/migrations No pending migrations to apply. [backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data. [backend] info: [TokenManager] Initialized new TokenManager instance for model: gpt-3.5-turbo [backend] info: [TokenManager] Returning existing instance for model: gpt-3.5-turbo [backend] info: [TELEMETRY ENABLED] Anonymous Telemetry enabled. Telemetry helps Mintplex Labs Inc improve AnythingLLM. [backend] info: prisma:info Starting a sqlite pool with 5 connections. [backend] info: [TELEMETRY SENT] {"event":"server_boot","distinctId":"56bdd1d4-f8ee-473e-847b-9dc2b8270ebc","properties":{"commit":"--","runtime":"docker"}} [backend] info: [CommunicationKey] RSA key pair generated for signed payloads within AnythingLLM services. [backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data. [backend] info: Primary server in HTTP mode listening on port 3001 [backend] info: [BackgroundWorkerService] Feature is not enabled and will not be started. [backend] info: [MetaGenerator] fetching custom meta tag settings... [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). at new OpenAI (/app/server/node_modules/openai/index.js:53:19) at openAiModels (/app/server/utils/helpers/customModels.js:84:18) at getCustomModels (/app/server/utils/helpers/customModels.js:40:20) at /app/server/endpoints/system.js:953:41 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) at next (/app/server/node_modules/express/lib/router/route.js:149:13) at /app/server/utils/middleware/multiUserProtected.js:60:7 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) at next (/app/server/node_modules/express/lib/router/route.js:149:13) at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5) [backend] info: [GeminiLLM] Using cached models API response. [backend] info: EmbeddingEngine changed from undefined to native - resetting undefined namespaces [backend] info: [Event Logged] - workspace_vectors_reset [backend] info: Resetting anythingllm managed vector namespaces for /usr/local/bin/docker-entrypoint.sh: line 7: 111 Illegal instruction (core dumped) node /app/server/index.js ----- Also, where should I enter the code you provided? I entered it into the default. There is no .conf file for domain, and I haven't edited the nginx.conf. /etc/nginx/sites-enabled/default content: https://docs.google.com/document/d/1yZM_jrl5e_eDGCuqNk1ZCF9zSE_BTKExGaOnWO0ubyc/edit?usp=sharing
Author
Owner

@timothycarambat commented on GitHub (Feb 17, 2025):

You are 301'ing port 80 in the second block which will go to the first blocks port 80 definition.

root /var/www/html; -> probably does not exist

You should have a single server block and that should be returning $host$request_uri, not a 301 to /var/www/html which likely does not exist.

What i posted above is the only server block your need. Also dont forget to reload the service when you change NGINX

@timothycarambat commented on GitHub (Feb 17, 2025): You are 301'ing port 80 in the second block which will go to the first blocks port 80 definition. ``` root /var/www/html; -> probably does not exist ``` You should have a _single_ server block and that should be returning $host$request_uri, not a 301 to /var/www/html which likely does not exist. What i posted above is the only server block your need. Also dont forget to reload the service when you change NGINX
yindo changed title from SyntaxError: Unexpected token '<', "<html> <h"... is not valid JSON to [GH-ISSUE #3223] SyntaxError: Unexpected token '<', "<html> <h"... is not valid JSON 2026-06-05 14:44:22 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2073