supabase
supabase copied to clipboard
studio in Docker only listens on one interface
Bug report
- [x] I confirm this is a bug with Supabase, not with my own application.
- [x] I confirm I have searched the Docs, GitHub Discussions, and Discord. relevant might be https://github.com/orgs/supabase/discussions/21558, but rather related to #28105
Describe the bug
I found that the server is being launched from server.js
:
https://github.com/supabase/supabase/blob/3e279dac7e0e08ed5b8bab66cafca68d6ad99bc1/apps/studio/Dockerfile#L60
In the server.js
, I found
const hostname = process.env.HOSTNAME || '0.0.0.0'
I tried to search this codebase but couldn't find the source of the file.
This results in the server only listening to studio:3000
but not on other interfaces it seems.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
-
Follow https://supabase.com/docs/guides/self-hosting/docker
-
attach at least two networks (network interfaces) to the
studio
container -
inside the container, install requirements for debugging
root@ba6dc8b3b0f8:/app# apt update root@ba6dc8b3b0f8:/app# apt install curl net-tools iproute2
I have those two interfaces with the respective IPs
-
eth1@if2497
with172.20.0.10/16
: this is the interface through which I would like to reach the server, which doesn't work -
eth0@if2511
with172.21.0.13/16
root@ba6dc8b3b0f8:/app# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2496: eth1@if2497: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:14:00:0a brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 172.20.0.10/16 brd 172.20.255.255 scope global eth1 valid_lft forever preferred_lft forever 2510: eth0@if2511: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:15:00:0d brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 172.21.0.13/16 brd 172.21.255.255 scope global eth0 valid_lft forever preferred_lft forever
-
-
check host resolution / server reachability
root@ba6dc8b3b0f8:/app# curl localhost:3000 curl: (7) Failed to connect to localhost port 3000 after 0 ms: Couldn't connect to server
bad 👎
root@ba6dc8b3b0f8:/app# curl studio:3000 /project/default
good 👍, as expected
-
check running servers
netstat -tulpn | grep 3000 tcp 0 0 172.21.0.13:3000 0.0.0.0:* LISTEN 1/next-server (v14.
The server is only listening on the
eth0@if2511
interface! That's the problem IMHO ⚠️.
Expected behavior
The server is available on all interfaces, not only the first. I can then wrap it with any reverse proxy, traefik
in my case.
Fix
If I launch my container with the environment variable HOSTNAME=0.0.0.0
, repeating the same steps as in 2.) - 4.), I see
root@525a492d6ae2:/app# netstat -tulpn | grep 3000
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 1/next-server (v14.
which is expected and now the studio is reachable on all interfaces as expected.
Also curl
shows the expected results:
/project/defaultroot@525a492d6ae2:/app# curl studio:3000
/project/default
root@525a492d6ae2:/app# curl localhost:3000
/project/defaultroot
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: Docker image on a Linux (TrueNas Scale) server
- Browser: Firefox and Chrome latest
- Version of supabase-js: docker image
supabase/studio:20240923-2e3e90c
- Version of Node.js: docker image
supabase/studio:20240923-2e3e90c
Additional context
Add any other context about the problem here.