Private URL not working (public URL works fine)

pauldps
HOBBY

a year ago

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_NETWORKING as 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

1 Replies

a year ago

hey @pauldps does this template work for you?
i was able to confirm it was working through the private network for me.

+-------------------------+------------------------------+----------+---------+-------+--------------+
|           ENV           |             Host             |  Scheme  | Status  | Error |   Duration   |
+-------------------------+------------------------------+----------+---------+-------+--------------+
| LIBSQL_PRIVATE_URL      | libsql.railway.internal      | libsql   | Success | N/A   | 14.043832ms  |
| LIBSQL_PUBLIC_URL       | libsql.railway.app           | libsql   | Success | N/A   | 43.969466ms  |
+-------------------------+------------------------------+----------+---------+-------+--------------+
|                                                                               Total | 44.105432ms  |
+-------------------------+------------------------------+----------+---------+-------+--------------+

pauldps
HOBBY

a year ago

how do I deploy it inside my project? it doesn't show up in the template list, and I can't seem to be able to select the project when I click "Deploy Now"


a year ago

haha blame cache, just hard refresh and it will show up


pauldps
HOBBY

a year ago

indeed 🙂 deploying now and trying to connect to it


pauldps
HOBBY

a year ago

is there a clever way to get a variable from a service to use it in another service? namely the private URL from the libSQL service


pauldps
HOBBY

a year ago

(I can just copy/paste in the meanwhile)


a year ago

LIBSQL_PRIVATE_URL=${{libSQL.SQLD_PRIVATE_URL}}

pauldps
HOBBY

a year ago

thanks, that worked!


a year ago

awsome


pauldps
HOBBY

a year ago

10MB memory usage on the libsql service ✨ will watch how it behaves with large amounts of data later


a year ago

i'd like to know that too!


pauldps
HOBBY

a year ago

API endpoint that hits the db = 4ms 🥳


pauldps
HOBBY

a year ago

about the 3s sleep, I should keep it for now, right?
looking forward to removing it when it's no longer needed (heard it's being planned) -- is there somewhere I can track this change?


a year ago

yeah it's still needed, unfortunately I don't have a place for you to track the new runtime, I haven't even heard anything about it lately


pauldps
HOBBY

a year ago

np, it would only affect app wakeup, and a 3s time on that is not too bad


a year ago

keep it hot instead 🙂


skizzinger
PRO

8 months ago

"haha blame cache, just hard refresh and it will show up" - how can I do a "hard refresh"?


8 months ago

I had said that 7 months ago, cache would no longer be an issue today


Private URL not working (public URL works fine) - Railway Help Station