R
Railwayβ€’3mo ago
pauldps

Private URL not working (public URL works fine)

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" ]
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...)
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
Solution:
hey @pauldps does this template work for you? https://railway.app/template/p121Tx i was able to confirm it was working through the private network for me. ``` +-------------------------+------------------------------+----------+---------+-------+--------------+ | ENV | Host | Scheme | Status | Error | Duration |...
Jump to solution
14 Replies
Percy
Percyβ€’3mo ago
Project ID: 71754a48-09bb-4250-b361-ff5ab1df9597
Solution
Brody
Brodyβ€’3mo ago
hey @pauldps does this template work for you? https://railway.app/template/p121Tx 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 |
+-------------------------+------------------------------+----------+---------+-------+--------------+
+-------------------------+------------------------------+----------+---------+-------+--------------+
| 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
pauldpsβ€’3mo 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"
Brody
Brodyβ€’3mo ago
haha blame cache, just hard refresh and it will show up
pauldps
pauldpsβ€’3mo ago
indeed πŸ™‚ deploying now and trying to connect to it 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 (I can just copy/paste in the meanwhile)
Brody
Brodyβ€’3mo ago
LIBSQL_PRIVATE_URL=${{libSQL.SQLD_PRIVATE_URL}}
LIBSQL_PRIVATE_URL=${{libSQL.SQLD_PRIVATE_URL}}
https://docs.railway.app/guides/variables#referencing-another-services-variable
pauldps
pauldpsβ€’3mo ago
thanks, that worked!
Brody
Brodyβ€’3mo ago
awsome
pauldps
pauldpsβ€’3mo ago
10MB memory usage on the libsql service ✨ will watch how it behaves with large amounts of data later
Brody
Brodyβ€’3mo ago
i'd like to know that too!
pauldps
pauldpsβ€’3mo ago
API endpoint that hits the db = 4ms πŸ₯³ 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?
Brody
Brodyβ€’3mo 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
pauldpsβ€’3mo ago
np, it would only affect app wakeup, and a 3s time on that is not too bad
Brody
Brodyβ€’3mo ago
keep it hot instead πŸ™‚
Want results from more Discord servers?
Add your server
More Posts