Problem with accessing Baserow’s API from within a docker container

Hey! :wave:

I’m having a problem with setting up local environment with Baserow + n8n using docker compose.

Both services are working fine, but I’m unable to connect to Baserow’s API from n8n (from within the same docker container).

Originally, BASEROW_PUBLIC_URL was set to http://localhost:8000. In this scenario, I could access Baserow’s API from the host with curl, but using n8n returned a “Site not found” page when calling the container name baserow:80 (internal port). Calling localhost:8000 returned also an error (service offline).

I changed BASEROW_PUBLIC_URL to http://baserow and then API got accessible from n8n and returned data, BUT the Web App returned the “Site not found” page / error.

Anyone faced a similar error and was able to solve it? :slightly_smiling_face:

If you’re working in a local environment, you can configure your services in the docker-compose.yml file to use the host’s network by adding:

network_mode: "host"

This would enable the containers to communicate directly over the host’s network interface, making localhost accessible to both the host and the containers.

Hey, thanks for the recommendation - ‘docker compose up’ threw an error, it is not allowed to bind to other ports when using network: “host”.

You will have to remove port mappings from your compose file as the services will use ports from the host.
Moreover you will need to make sure that the ports you want your containers to use are free on the host.

In case one or more ports are already taken you can easily change ports for Baserow and n8n:

https://baserow.io/docs/installation/configuration

1 Like

Thanks! I checked and I only have n8n, UI Bakery and Baserow in a single container and none of their ports overlap.

I believe it’s safe for me then to delete port mappings from docker-compose.yml and do not modify env variables at all, right?

In this case, would those services be still available at http://localhost:{{port #}}

I am aware of how basic my questions may sound like, but I appreciate all the help a lot! :slightly_smiling_face:

1 Like

Exactly. After removing the port mapping, services should be available on localhost + default_port :blush:

1 Like

Hi! Unfortunately, neither Baserow nor n8n are accessible in this scenario. Here’s the content of my docker-compose file. What am I doing wrong? :sweat_smile:

services:
  baserow:
    container_name: baserow
    image: baserow/baserow:1.28.0
    environment:
      BASEROW_PUBLIC_URL: 'http://localhost:8000'
    network_mode: "host"
    volumes:
      - baserow_data:/baserow/data
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    network_mode: "host"
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ~/Users/michalplatek/n8n-local-files:/files

volumes:
  traefik_data:
    external: true
  n8n_data:
    external: true
  baserow_data: 

What output/errors do you get?

I tested your compose file on a VM and it it working:

  • Baserow Frontend :white_check_mark:
  • N8N Frontend :white_check_mark:
  • Get Data from Baserow in N8N :white_check_mark:

Three things to note here:

  1. Baserow Frontend can be reached on port 80. So your URL would be http://localhost
  2. In N8N when setting up credentials you would also set the host for Baserow to http://localhost
  3. You need to make sure that all of the ports the the docker images needs are available on the host: 80, 5432, 6379, 8000, 3000 for Baserow + 5678 for n8n

I hit this same issue and tried a few different things until I found something that I believe is working.

The key pieces seem to be…

  1. Using the same non-localhost hostname in the “docker network” settings and in the “external network” (DNS/hosts file)
  2. Mapping port 80 to some other, available, external port (which is the aspect of this that probably makes all of it necessary)
  3. Setting the BASEROW_PUBLIC_URL to have both the hostname and the external port
  4. Adding the hostname (not URL - i.e. no protocol / no port) to BASEROW_EXTRA_ALLOWED_HOSTS
  5. Using the docker-internal-hostname (default port 80) URL in n8n (i.e. without appending the mapped external port)

The docker-compose for baserow looks like this:

services:
  baserow:
    container_name: baserow
    hostname: baserow
    image: baserow/baserow:1.29.3
    environment:
      BASEROW_PUBLIC_URL: 'http://baserow:8980'
      BASEROW_EXTRA_ALLOWED_HOSTS: 'baserow'
    ports:
      - "8980:80"
      - "8943:443"
    volumes:
      - baserow_data:/baserow/data
volumes:
  baserow_data:

The n8n credentials item has:

Host: `http://baserow`

External DNS / name resolution

Hostname baserow (outside docker) resolves to the docker-host machine’s address (using the /etc/hosts file).

The baserow UI is reachable from a browser at

http://baserow:8980/workspace/...

Note about “localhost”

Not sure this would work without assigning a hostname other than localhost both inside and outside Docker.