oskar-gmerek / surreal-sveltekit

A Starter Kit with SurrealDB and Svelte [ SvelteKit ], featuring Authentication and CRUD Operations + Realtime
MIT License
72 stars 3 forks source link

Error: connect ECONNREFUSED 127.0.0.1:8000 #2

Closed oren closed 8 months ago

oren commented 9 months ago
npm run multitaskum:developum

> surreal-sveltekit@0.0.1 multitaskum:developum
> docker compose up -d && vite dev --host

[+] Running 1/0
 ✔ Container database  Started                                                                                                                            0.0s

  VITE v4.5.1  ready in 902 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://10.0.0.243:5173/
  ➜  Network: http://10.0.0.234:5173/
  ➜  Network: http://172.19.0.1:5173/
  ➜  press h to show help

I go to http://localhost:5173/ in the browser and see the following:

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: connect ECONNREFUSED 127.0.0.1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8000
}

Node.js v18.18.0

BTW, I am on Ubuntu 22.04.3 LTS

KyahWill commented 9 months ago

Is the database running as well?

oren commented 9 months ago

How do I verify that?

oskar-gmerek commented 9 months ago

This error usually means that database instance is not running or is not reachable on 127.0.0.1:8000

You can check what is running on the port 8000 with this cmd: sudo lsof -i:8000

If there is a conflict then you can

kill process by cmd: kill -9 or change ports docker-compose and .env to something else

This error can also happens when network is misconfigurated, or ports are blocked by firewall etc.

Firstly check if there is no conflicts on port 8000 and let me know

oren commented 9 months ago

the lsof command shows nothing. I tried changing both .env and docker-compose.yml to 8001 but got the same error. Maybe i need to remove my docker image or stop it from running (if it's running already, I am not sure)?

Also, in docker-compose I tried changing the number twice (it shows up twice in one line) and i also tried to only change the first number, but in both cases I got the same error.

 - 8000:8000
oskar-gmerek commented 9 months ago

That sounds like some kind of problem with Docker. I will suggest to restart docker engine, remove SurrealDB container and turn off all others containers (just for testing). After restart run: npm run multitaskum:developum again.

Let me know if that helps, if not then let me know if there was running container for surrealdb, if not let me know if SurrealDB container exists at all.

oren commented 9 months ago

ok. I'll will look up the docker documentation (unless you know what commands I should run) and report back!

oren commented 9 months ago

I found the docker commands:

systemclt start docker
docker ps
docker stop d728f5ebb68b
docker rm d728f5ebb68b
npm run multitaskum:developum

And it looks like the container is crashing every few seconds:

docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS                        PORTS     NAMES
d728f5ebb68b   surrealdb/surrealdb:latest   "/surreal start --al…"   17 seconds ago   Restarting (1) 1 second ago             database
oskar-gmerek commented 8 months ago

I apologize for the late reply, but I don't have constant access to the Internet as I am abroad right now.

I can't reproduce this. I clone repository, run bun install and bun run multitaskum:developum and everything just works.

Please try to change in .env file DB_LOG_LEVEL=INFO to =FULL and check the inside logs of the container by cmd: docker logs <container id>, maybe there will be any helpful information that can help debug this.

With current info I can only guess that there is a problem with read/write access on db folder. So you can check this as well.

oskar-gmerek commented 8 months ago

I am closing this matter due to insufficient information for replication, and it has also been inactive for over three weeks. Please feel free to reopen it if necessary.