immich icon indicating copy to clipboard operation
immich copied to clipboard

500 : Converting circular structure to JSON

Open n8jadams opened this issue 3 years ago • 30 comments
trafficstars

I am trying to run Immich on my Unraid server using the official Portainer-CE app. Once it's set up, I navigate to http://:2283, I see the favicon load and the body of the page shows the following error:

500
Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle
TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle

docker-compose.yml

version: "3.8"

services:
  immich-server:
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-server.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - redis
      - database
    restart: always

  immich-microservices:
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-microservices.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    image: altran1502/immich-machine-learning:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - database
    restart: always

  immich-web:
    image: altran1502/immich-web:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      PG_DATA: /var/lib/postgresql/data
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: altran1502/immich-proxy:release
    ports:
      - 2283:80
    logging:
      driver: none
    depends_on:
      - immich-server
    restart: always

volumes:
  pgdata:

.env

DB_USERNAME=postgres
DB_PASSWORD=REDACTED
DB_DATABASE_NAME=immich
UPLOAD_LOCATION=/mnt/user/cloud-storage/app-configs/immich
JWT_SECRET=REDACTED
ENABLE_MAPBOX=false
VITE_SERVER_ENDPOINT=http://<my-ip>:2283/api

Task List

Please complete the task list below. We need this information to help us reproduce the bug or point out problems in your setup. You are not providing enough info may delay our effort to help you.

  • [x] I have read thoroughly the README setup and installation instructions.
  • [x] I have included my docker-compose file.
  • [x] I have included my redacted .env file.
  • [x] I have included information on my machine, and environment.

n8jadams avatar Aug 01 '22 20:08 n8jadams

Can you check what do you get from /api/server-info/ping?

Also do you have any firewall on? If so, can you allow port 2283?

alextran1502 avatar Aug 01 '22 21:08 alextran1502

I had forgotten to port forward 2283, but I got the same thing after doing that.

502 Bad Gateway nginx error

n8jadams avatar Aug 01 '22 22:08 n8jadams

Is your VITE_SERVER_ENDPOINT your local ip or external domain name?

alextran1502 avatar Aug 01 '22 23:08 alextran1502

it is my public ip, should I make it my internal ip?

n8jadams avatar Aug 02 '22 00:08 n8jadams

If you try to access your instance over https://immich.yourdomain.com then your VITE_SERVER_ENDPOINT will need to be https://immich.yourdomain.com/api

alextran1502 avatar Aug 02 '22 01:08 alextran1502

And vice versa, if you access the site from your local IP, let's say http://192.168.1.50:2283 then your VITE_SERVER_ENDPOINT will be http://192.168.1.50:2283/api

alextran1502 avatar Aug 02 '22 01:08 alextran1502

@n8jadams Hello, has this issue been resolved?

alextran1502 avatar Aug 03 '22 05:08 alextran1502

The reason why I never responded was because I was setting up a domain name and https. But now I changed the VITE_SERVER_ENDPOINT to https://immich.mydomain.com/api and I'm getting the exact same error.

And at https://immich.mydomain.com/api/server-info/ping I'm getting the same 502 error.

n8jadams avatar Aug 03 '22 19:08 n8jadams

what is your reverse proxy setup like?

alextran1502 avatar Aug 03 '22 20:08 alextran1502

My domain points all requests (on all subdomains) to my public ip, my router forwards requests from 2283 to my private ip port 2283, and then nginx (nginx proxy manager) forwards requests from http://immich.mydomain.com to my public ip on port 2283...

n8jadams avatar Aug 03 '22 20:08 n8jadams

I think what you will want to do is something similar to the setup below.

server {
  listen       80;
  server_name  immich.mydoamin.com;

  location / {
    proxy_pass  http://your-local-machine-ip-running-immich:2283;
  }
}

alextran1502 avatar Aug 03 '22 21:08 alextran1502

Had the same issue. Adding /photos to the url on client-side solved it: http://immich.mydomain.com/photos

spammads avatar Aug 04 '22 10:08 spammads

Had the same issue, all fresh install with docker-compose. Tried to access the WebUI over http://IpAddressfromServer:2283 and got the message:

500

Converting circular structure to JSON
    --> starting at object with constructor 'ClientRequest'
    |     property 'socket' -> object with constructor 'Socket'
    --- property '_httpMessage' closes the circle

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'ClientRequest'
    |     property 'socket' -> object with constructor 'Socket'
    --- property '_httpMessage' closes the circle


As @CKranebitter pointed out: adding /photos after the port (http://IpAddressFromServer:2283/photos) redirected me to http://IpAddressFromServer:2283/auth/login and I was greeted with the login Page from immich.

But now I am greeted with the login page and not with the "Admin-User" creation page! So can not create admin account. Need to look which subfolder / path is used for the Admin Account creation.

So it seems, that the automatic redirection after creating the immich container(s) is not working properly.

rondadon avatar Aug 04 '22 15:08 rondadon

@rondadon Can you share your .env file?

alextran1502 avatar Aug 04 '22 16:08 alextran1502

Just to jump in here, I'm using the default .env file. The only thing I've changed is the UPLOAD_LOCATION and the VITE_SERVER_ENDPOINT variables. The Upload Location is set to a folder on my system. For the Endpoint, I've tried my server's IP address as well as the FQDN.

I'm able to get to /photos and /auth/login, but not /auth/register

When I go to /auth/register, I get the same 500 errors as @rondadon

I've changed the :release tags to :latest to see if that fixes anything. It doesn't.

I'm using CloudFlare Tunnels for remote access. I'm on OMV 6 for testing purposes.

dnburgess avatar Aug 04 '22 18:08 dnburgess

@dnburgess VITE_SERVER_ENDPOINT is usually the value that most get wrong, can you share yours? You shouldn't use the latest tag since it might not work properly, please use the release tag instead.

alextran1502 avatar Aug 04 '22 18:08 alextran1502

@dnburgess is your CloudFlare tunnel allow port 2283? I am not sure if you are accessing through a reverse proxy or direct access on port 2283. If you can share detailed information about your setting, having another pair of eyes to take a look at might spot something.

alextran1502 avatar Aug 04 '22 18:08 alextran1502

@alextran1502 the Cloudflare tunnel points directly to http://192.168.1.65:2283.

My VITE_SERVER_ENDPOINT is https://photos.mysite.com/api

I've changed back to :release as :lastest was just testing to see if it fixed anything.

Strangely, as I write this, everything seems to have started working after switching back to :release.

I'm going to deploy this on another server for additional testing

dnburgess avatar Aug 04 '22 19:08 dnburgess

@dnburgess your VITE_SERVER_ENDPOINT should be http://192.168.1.65:2283/api

Edited: strange, it works?

alextran1502 avatar Aug 04 '22 19:08 alextran1502

@alextran1502 in a previous comment you said this:

If you try to access your instance over https://immich.yourdomain.com then your VITE_SERVER_ENDPOINT will need to be https://immich.yourdomain.com/api

So that's what I did

dnburgess avatar Aug 04 '22 19:08 dnburgess

@alextran1502 in a previous comment you said this:

If you try to access your instance over https://immich.yourdomain.com then your VITE_SERVER_ENDPOINT will need to be https://immich.yourdomain.com/api

So that's what I did

Ah so your CloudFlare tunnel is a reverse proxy that point your public domain https://photos.mysite.com to http://192.168.1.65:2283. Then this setup of VITE_SERVER_ENDPOINT=https://immich.yourdomain.com/api is correct

alextran1502 avatar Aug 04 '22 19:08 alextran1502

Just as an FYI: I spun up a new VM running Docker in Proxmox and everything came up exactly as one would expect and no issues, so I'm not sure what was going on, but everything on the new setup is working.

dnburgess avatar Aug 04 '22 21:08 dnburgess

To follow up with this, I see the following

Screen Shot 2022-08-04 at 3 41 53 PM

I'm pretty sure I have the .env set up right. Unless there's some trick to getting this to work with Portainer?

n8jadams avatar Aug 04 '22 21:08 n8jadams

To follow up with this, I see the following

Screen Shot 2022-08-04 at 3 41 53 PM

I'm pretty sure I have the .env set up right.

Unless there's some trick to getting this to work with Portainer?

Can you share the exact setup of yours?

alextran1502 avatar Aug 04 '22 23:08 alextran1502

@n8jadams There is a new release that is supposed to simplify the setup. Please try again and let me know if this issue is resolved. https://github.com/immich-app/immich/releases/tag/v1.20.0_30-dev

alextran1502 avatar Aug 07 '22 18:08 alextran1502

I think this is a step in the right direction.

Now the page loads initially and looks good and then the requests to https://immich.mydomain.com/api/user/me and https://immich.mydomain.com/api/user/count give a 502 response

(EDIT: The same applies from http://192.168.x.y:2283 and http://my-public-ip:2283)

n8jadams avatar Aug 10 '22 16:08 n8jadams

Hi @n8jadams, are you still facing this error with the latest version?

panoti avatar Aug 29 '22 10:08 panoti

Hi, I have exactly the same problem :

  • https://immich.mydomain.com leading to "AxiosError" (see below) after a request to /api/user/count
  • https://immich.mydomain.com/auth/register leading to "circular error" (see below)
  • https://immich.mydomain.com/albums or /photos redirecting to /auth/login
  • https://immich.mydomain.com/auth/login seems good but I don't have credentials
  • https://immich.mydomain.com/api/server-info/ping not found No errors found in the logs of immich microservices or immich machine learning.

"Circular error" image

"AxiosError" image

"login page" image

I have to admit that my setup is not exactly standard, as I'm not running under docker but have compiled everything on Debian. I'm using a SSL certified url with a proxy pass through nginx to 0.0.0.0:3000 where the frontend is listening. By the way, that would be great to have an option to set the vite server to listen to a chosen port.

EDIT : solved adding 127.0.0.1 immich-server to my /etc/hosts However, I would still be interested to control the server and web ports

Limezy avatar Aug 31 '22 11:08 Limezy

Hi @Limezy, we stick heavily with docker, so there are some issues if you run outside docker. I hope immich team will support dockerless (maybe with pm2) soon.

panoti avatar Sep 04 '22 17:09 panoti

Thanks for your reply

Limezy avatar Sep 05 '22 04:09 Limezy