I've spun a new database service inside my project to run a libSQL database (https://github.com/tursodatabase/libsql/blob/main/docs/DOCKER.md).
The service itself is running fine and I can connect to it via its public URL from another service (a Bun API) inside the same project.
But using the private URL to connect does not work.
This is what I've done:
- Enabled private networking for both apps
- Added 3s of sleep before the start command. I can see the delays in my logs. From my Dockerfile:
ENTRYPOINT [ "/bin/sh", "-c", "sleep 3; ./migrator && ./server" ]
- "migrator" is an executable that runs migrations on my database, and "server" is the API itself. The errors are coming from my migrator command.
- Manually set the PORT env variable in the libSQL service so that I can use it in the private URL from the API
- (just in case) Added
ENABLE_ALPINE_PRIVATE_NETWORKINGas true in my API service. I'm using an external image in my Dockerfile that I'm not sure is Alpine, so this might not be having an effect.
API logs (with private URL and port):
Connecting to database: http://webmuds-libsql.railway.internal:8080
ConnectionRefused: Unable to connect. Is the computer able to access the url?
path: "http://webmuds-libsql.railway.internal:8080/v2/pipeline";
Connecting to database: http://webmuds-libsql.railway.internal:8080
ConnectionRefused: Unable to connect. Is the computer able to access the url?
path: "http://webmuds-libsql.railway.internal:8080/v2/pipeline";
(... repeat until health check timeout...)
Project ID: 71754a48-09bb-4250-b361-ff5ab1df9597