500 Error when navigating away from home page

Hello,

I’m trying to establish a family newsletter with a self-hosted instance through docker-compose. I just found Ghost this last week, and I’m fairly new to docker-compose.

When I navigate away from the home page to a post or the About page, I get a 500 Internal server error.

Here is the log content of the error:

[2024-11-10 01:16:07] ERROR "GET /about/" 500 720ms
An unexpected error occurred, please try again.
"Cannot read properties of null (reading 'handle')"
Error ID:
    5d37dae0-9f01-11ef-bf4a-ed02d1511e27
Error Code: 
    UNEXPECTED_ERROR
----------------------------------------
TypeError: Cannot read properties of null (reading 'handle')
    at prepareError (/var/lib/ghost/versions/5.100.1/node_modules/@tryghost/mw-error-handler/lib/mw-error-handler.js:113:19)
    at CollectionRouter._respectDominantRouter (/var/lib/ghost/versions/5.100.1/core/frontend/services/routing/ParentRouter.js:90:20)
    at paramCallback (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:415:7)
    at param (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:395:5)
    at Function.process_params (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:421:3)
    at next (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:280:10)
    at CollectionRouter._prepareEntryContext (/var/lib/ghost/versions/5.100.1/core/frontend/services/routing/CollectionRouter.js:123:9)
    at Layer.handle (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/layer.js:95:5)
    at Layer.handle [as handle_request] (/opt/dynatrace/oneagent/agent/bin/1.306.0.20241107-111004/any/nodejs/nodejsagent.js:8931:18)
    at trim_prefix (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:328:13)
    at /var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:346:12)
    at next (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:280:10)
    at /var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:646:15
    at next (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:265:14)

Here is an anonymized of my compose file:

    services:
      ghost:
        container_name: ghost
        image: ghost:latest
        restart: unless-stopped
        ports:
          - server-port:2368
        environment:
          # see https://ghost.org/docs/config/#configuration-options
          url: https://example.com
          # mail configuration
          mail__transport: SMTP
          mail__options__service: Mailgun
          mail__options__host: smtp.mailgun.org
          mail__options__port: 587
          mail__options__auth__user: user@example.com
          mail__options__auth__pass: your_mailgun_password
          mail__from: noreply@example.com
          # database configuration      
          database__client: mysql
          database__connection__host: db #service name of the database
          database__connection__user: ghost #database user
          database__connection__password: your_database_password #database password
          database__connection__database: db #database name
        volumes:
          - ./docker/dockge/ghost:/var/lib/ghost/content
        networks:
          myNetwork::
            ipv4_address: <my_ip>
        labels:
          - traefik.enable=true
          - traefik.http.routers.ghost.rule=Host(`example.com`)
          - traefik.http.routers.ghost.entrypoints=https
          - traefik.http.routers.ghost.tls=true
          - traefik.http.services.ghost.loadbalancer.server.port=2368
      db:
        container_name: db
        image: mysql:9
        restart: unless-stopped
        environment:
          MYSQL_ROOT_PASSWORD: your_database_password
          MYSQL_USER: ghost
          MYSQL_PASSWORD: your_database_password
          MYSQL_DATABASE: db
          MYSQL_ROOT_HOST: 172.*.*.*
        networks:
          myNetwork:
            ipv4_address: <my_ip>
        volumes:
          - ./docker/dockge/ghost_db:/var/lib/mysql
    networks:
      myNetwork:
        external: true

I’m trying to figure out if I did anything wrong to corrupt any default settings that handle routes between pages or if this is a bug in the latest versions of Ghost. No themes have changed from the default yet, but I set up Mailgun, and it appears to be working as intended.

did you upload a custom routes.yaml? If so, could you please post a copy of it?

Hi there, I did not change anything from the routes.yaml file yet but here is a copy of it:

routes:

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

I found part of the issue. My server has some monitoring from Dynatrace that I was experimenting with and it was auto-injecting into the container. If I turn off the injection into this container it resolves the error. Although, I would like to have some monitoring on the process as well in the future to let me know if it ever goes down or if there are other issues that I don’t know about.

Error Stacktrace from Dynatrace:

[2024-11-11 03:58:42] ERROR "GET /about/" 500 43ms
An unexpected error occurred, please try again.
"Cannot read properties of null (reading 'handle')"
Error ID:
    3e102c40-9fe1-11ef-a844-db51bca4e067
Error Code:
    UNEXPECTED_ERROR
----------------------------------------
TypeError: Cannot read properties of null (reading 'handle')
    at prepareError (/var/lib/ghost/versions/5.100.1/node_modules/@tryghost/mw-error-handler/lib/mw-error-handler.js:113:19)
    at CollectionRouter._respectDominantRouter (/var/lib/ghost/versions/5.100.1/core/frontend/services/routing/ParentRouter.js:90:20)
    at paramCallback (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:415:7)
    at param (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:395:5)
    at Function.process_params (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:421:3)
    at next (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:280:10)
    at CollectionRouter._prepareEntryContext (/var/lib/ghost/versions/5.100.1/core/frontend/services/routing/CollectionRouter.js:123:9)
    at Layer.handle (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/layer.js:95:5)
    at b.runFunctionInContext (/opt/dynatrace/oneagent/agent/bin/1.306.0.20241107-111004/any/nodejs/nodejsagent.js:2616:80)
    at b.runFunction (/opt/dynatrace/oneagent/agent/bin/1.306.0.20241107-111004/any/nodejs/nodejsagent.js:2604:19)
    at Layer.handle [as handle_request] (/opt/dynatrace/oneagent/agent/bin/1.306.0.20241107-111004/any/nodejs/nodejsagent.js:8931:18)
    at trim_prefix (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:328:13)
    at /var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:346:12)
    at next (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:280:10)
    at /var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:646:15
    at next (/var/lib/ghost/versions/5.100.1/node_modules/express/lib/router/index.js:265:14)