[GH-ISSUE #670] Cannot connect to the Vite Dev Server on http://localhost:5173 #435

Closed
opened 2026-03-02 11:49:49 +03:00 by kerem · 13 comments
Owner

Originally created by @YoFoon on GitHub (Nov 18, 2024).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/670

Describe the Bug

Google Chrome plugin prompts me

Vite Dev Mode

Cannot connect to the Vite Dev Server on http://localhost:5173/

Double-check that Vite is working and reload the extension.

This page will close when the extension reloads.

ADN
Google Chrome plugin auto reload。。

Steps to Reproduce

  • run pnpm install in the root of the repo
  • cp .env.sample .env, and update .env
    • DATA_DIR=/Users/yofoon/Documents/hoarder/data
    • NEXTAUTH_URL=http://localhost:3000
    • NEXTAUTH_SECRET=sOlazDIXPR6FsmOYzsxls6xxxxxxxxx
    • MEILI_ADDR=http://127.0.0.1:7700 #docker is running
    • OPENAI_API_KEY=sk-proj-cbuY3XUprmF7leh9tRnab_xxxxx
  • run pnpm dev in the root of the repo
  • run pnpm run db:migrate in the root of the repo
  • load dist to chrome extension #apps/browser-extension/dist

Expected Behaviour

Normal use

Screenshots or Additional Context

image

Device Details

No response

Exact Hoarder Version

master

Originally created by @YoFoon on GitHub (Nov 18, 2024). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/670 ### Describe the Bug Google Chrome plugin prompts me Vite Dev Mode Cannot connect to the Vite Dev Server on http://localhost:5173/ Double-check that Vite is working and reload the extension. This page will close when the extension reloads. ADN Google Chrome plugin auto reload。。 ### Steps to Reproduce - run `pnpm install` in the root of the repo - `cp .env.sample .env`, and update .env - DATA_DIR=/Users/yofoon/Documents/hoarder/data - NEXTAUTH_URL=http://localhost:3000 - NEXTAUTH_SECRET=sOlazDIXPR6FsmOYzsxls6xxxxxxxxx - MEILI_ADDR=http://127.0.0.1:7700 #docker is running - OPENAI_API_KEY=sk-proj-cbuY3XUprmF7leh9tRnab_xxxxx - run `pnpm dev` in the root of the repo - run `pnpm run db:migrate` in the root of the repo - load `dist` to chrome extension #apps/browser-extension/dist ### Expected Behaviour Normal use ### Screenshots or Additional Context <img width="213" alt="image" src="https://github.com/user-attachments/assets/1859c18c-1222-4501-8bc9-0be8b0631d35"> ### Device Details _No response_ ### Exact Hoarder Version master
kerem closed this issue 2026-03-02 11:49:49 +03:00
Author
Owner

@MohamedBassem commented on GitHub (Nov 18, 2024):

did you run in 'pnpm dev' in the root of the repo or in the extension directory?

<!-- gh-comment-id:2482853607 --> @MohamedBassem commented on GitHub (Nov 18, 2024): did you run in 'pnpm dev' in the root of the repo or in the extension directory?
Author
Owner

@MohamedBassem commented on GitHub (Nov 18, 2024):

'pnpm dev' should be ran inside the extension directory. It'll start a server that needs to be running during the development of the plugin as the plugin will attempt to connect to this server for hot reloads, etc

<!-- gh-comment-id:2482857967 --> @MohamedBassem commented on GitHub (Nov 18, 2024): 'pnpm dev' should be ran inside the extension directory. It'll start a server that needs to be running during the development of the plugin as the plugin will attempt to connect to this server for hot reloads, etc
Author
Owner

@YoFoon commented on GitHub (Nov 19, 2024):

image

run pnpm dev inside the extension directory, get 'Cannot connect to the Vite Dev Server'

image

run pnpm dev in the root of the repo, also get 'Cannot connect to the Vite Dev Server'

  • dist
    apps/browser-extension/dist/assets/loading-page-1924caaa.js
const VITE_URL = "http://localhost:5173";
document.body.innerHTML = `
<div
      id="app"
      style="
        border: 1px solid #ddd;
        padding: 20px;
        border-radius: 5px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      "
    >
      <h1 style="color: #333">Vite Dev Mode</h1>
      <p style="color: #666">
        Cannot connect to the Vite Dev Server on <a href="${VITE_URL}">${VITE_URL}</a>
      </p>
      <p style="color: #666">
        Double-check that Vite is working and reload the extension.
      </p>
      <p style="color: #666">
        This page will close when the extension reloads.
      </p>
      <button
        style="
          padding: 10px 20px;
          border: none;
          background-color: #007bff;
          color: #fff;
          border-radius: 5px;
          cursor: pointer;
        "
      >
        Reload Extension
      </button>
    </div>`;
document.body.querySelector("button")?.addEventListener("click", () => {
  chrome.runtime.reload();
});
let tries = 0;
let ready = false;
do {
  try {
    await fetch(VITE_URL);
    ready = true;
  } catch {
    const timeout = Math.min(100 * Math.pow(2, ++tries), 5e3);
    console.log(`[CRXJS] Vite Dev Server is not available on ${VITE_URL}`);
    console.log(`[CRXJS] Retrying in ${timeout}ms...`);
    await new Promise((resolve) => setTimeout(resolve, timeout));
  }
} while (!ready);
location.reload();
<!-- gh-comment-id:2484433178 --> @YoFoon commented on GitHub (Nov 19, 2024): <img width="716" alt="image" src="https://github.com/user-attachments/assets/404fb458-fe85-45b2-8398-6f5291a4b287"> run `pnpm dev` inside the extension directory, get 'Cannot connect to the Vite Dev Server' <img width="985" alt="image" src="https://github.com/user-attachments/assets/7cc7f030-1487-4f12-b58f-817039b45a63"> run `pnpm dev` in the root of the repo, also get 'Cannot connect to the Vite Dev Server' - dist apps/browser-extension/dist/assets/loading-page-1924caaa.js ``` const VITE_URL = "http://localhost:5173"; document.body.innerHTML = ` <div id="app" style=" border: 1px solid #ddd; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); " > <h1 style="color: #333">Vite Dev Mode</h1> <p style="color: #666"> Cannot connect to the Vite Dev Server on <a href="${VITE_URL}">${VITE_URL}</a> </p> <p style="color: #666"> Double-check that Vite is working and reload the extension. </p> <p style="color: #666"> This page will close when the extension reloads. </p> <button style=" padding: 10px 20px; border: none; background-color: #007bff; color: #fff; border-radius: 5px; cursor: pointer; " > Reload Extension </button> </div>`; document.body.querySelector("button")?.addEventListener("click", () => { chrome.runtime.reload(); }); let tries = 0; let ready = false; do { try { await fetch(VITE_URL); ready = true; } catch { const timeout = Math.min(100 * Math.pow(2, ++tries), 5e3); console.log(`[CRXJS] Vite Dev Server is not available on ${VITE_URL}`); console.log(`[CRXJS] Retrying in ${timeout}ms...`); await new Promise((resolve) => setTimeout(resolve, timeout)); } } while (!ready); location.reload(); ```
Author
Owner

@MohamedBassem commented on GitHub (Nov 19, 2024):

Ah sorry, run pnpm run dev instead inside the extension directory.

<!-- gh-comment-id:2484435325 --> @MohamedBassem commented on GitHub (Nov 19, 2024): Ah sorry, run `pnpm run dev` instead inside the extension directory.
Author
Owner

@MohamedBassem commented on GitHub (Nov 19, 2024):

just to confirm, are you loading the extension on the same machine where you're running pnpm run dev?

<!-- gh-comment-id:2484436756 --> @MohamedBassem commented on GitHub (Nov 19, 2024): just to confirm, are you loading the extension on the same machine where you're running `pnpm run dev`?
Author
Owner

@MohamedBassem commented on GitHub (Nov 19, 2024):

Also, do you keep pnpm run dev running while you're loading the extension in the browser?

<!-- gh-comment-id:2484437293 --> @MohamedBassem commented on GitHub (Nov 19, 2024): Also, do you keep `pnpm run dev` running while you're loading the extension in the browser?
Author
Owner
<!-- gh-comment-id:2484459826 --> @YoFoon commented on GitHub (Nov 19, 2024): <img width="1658" alt="image" src="https://github.com/user-attachments/assets/6b041f13-f819-4a7e-a6ab-ef23f30d4fc1"> https://github.com/user-attachments/assets/98ff2e17-1c34-4093-a974-480078e8b9df
Author
Owner

@YoFoon commented on GitHub (Nov 19, 2024):

  • remove the extension
  • load dist to chrome extension
    it's also not works
<!-- gh-comment-id:2484467109 --> @YoFoon commented on GitHub (Nov 19, 2024): - remove the extension - load dist to chrome extension it's also not works
Author
Owner

@MohamedBassem commented on GitHub (Nov 19, 2024):

that's very weird.

Maybe try pnpm run dev --host 0.0.0.0, if that doesn't work, your only option then is to do a prod build with pnpm run build and constantly rebuild+reload everytime you do a change. Not optimal, but I don't see a way around it.

<!-- gh-comment-id:2484470269 --> @MohamedBassem commented on GitHub (Nov 19, 2024): that's very weird. Maybe try `pnpm run dev --host 0.0.0.0`, if that doesn't work, your only option then is to do a prod build with `pnpm run build` and constantly rebuild+reload everytime you do a change. Not optimal, but I don't see a way around it.
Author
Owner

@YoFoon commented on GitHub (Nov 19, 2024):

image
  • pnpm run build inside the extension directory
  • load dist to chrome extension

any other configurations that need to be noted?

<!-- gh-comment-id:2484667117 --> @YoFoon commented on GitHub (Nov 19, 2024): <img width="400" alt="image" src="https://github.com/user-attachments/assets/3e568b12-14fe-4983-a844-f5a0e154fe77"> - `pnpm run build` inside the extension directory - load dist to chrome extension any other configurations that need to be noted?
Author
Owner

@MohamedBassem commented on GitHub (Nov 19, 2024):

nope. You're good to go now. Just point the extension at your hoarder deployment and you can use it.

<!-- gh-comment-id:2484980544 --> @MohamedBassem commented on GitHub (Nov 19, 2024): nope. You're good to go now. Just point the extension at your hoarder deployment and you can use it.
Author
Owner

@YoFoon commented on GitHub (Nov 20, 2024):

It works for me in dev mode.

  • update "@crxjs/vite-plugin": "2.0.0-beta.28"
  • add this to vite config
server: {
    port: 5173,
    strictPort: true,
    hmr: {
      protocol: "ws",
      host: "localhost",
      port: 5173,
    },
  },

You saved my life!!
Thank you!! @MohamedBassem

<!-- gh-comment-id:2487793981 --> @YoFoon commented on GitHub (Nov 20, 2024): It works for me in dev mode. - update "@crxjs/vite-plugin": "2.0.0-beta.28" - add this to vite config ```javascript server: { port: 5173, strictPort: true, hmr: { protocol: "ws", host: "localhost", port: 5173, }, }, ``` You saved my life!! Thank you!! @MohamedBassem
Author
Owner

@MohamedBassem commented on GitHub (Nov 24, 2024):

Actually thank you for letting me know how to fix it. Sent a fix in 1a2b600.

<!-- gh-comment-id:2496323328 --> @MohamedBassem commented on GitHub (Nov 24, 2024): Actually thank you for letting me know how to fix it. Sent a fix in 1a2b600.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#435
No description provided.