How to create Postgres DB and Initiate public network URL via GitLab
Anonymous
PROOP

5 months ago

Dear Support,

Currently, there is no way to create a PostgreSQL database/Initiate public Network URL to my project using either a Personal Access Token or a Project Access Token

A similar issue was previously raised at the following URL: https://station.railway.com/questions/unauthorized-please-login-with-railway-22d6a137

Could you please provide guidance on how to resolve this authentication issue or suggest an alternative method for database creation via API tokens?

Regards,
Terence

$10 Bounty

12 Replies

Railway
BOT

5 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


Anonymous
PROOP

5 months ago

It seems that the Railway CLI does not have a direct command for creating databases, i cant do it through GitLab.

Domain configuration must be done through the Dashboard?

These operations cannot be automated via the API?


5 months ago

you can directly add these via the CLI, check railway docs here that support it through the PAT. once creating the respective service, you can connect to it through the public network and configure it


yeeet

you can directly add these via the CLI, check railway docs here that support it through the PAT. once creating the respective service, you can connect to it through the public network and configure it

Anonymous
PROOP

5 months ago

Thanks for the reply.

I actually referred to that page before and tried it myself with AI assistance, however it still doesn't work for me.

I wonder if there is any working script that can be shared. Thanks in advance.


Anonymous
PROOP

5 months ago

mag emoji Trying domain creation for service: Carpool

$ echo "wrench emoji Attempting domain creation with Railway CLI..."

wrench emoji Attempting domain creation with Railway CLI...

$ NODE_TLS_REJECT_UNAUTHORIZED=0 RAILWAY_TOKEN=$RAILWAY_TOKEN npx railway domain --service CarPool || echo "warning emoji Domain creation failed for service 'CarPool', trying capitalized version..."

Unauthorized. Please login with railway login

warning emoji Domain creation failed for service 'CarPool', trying capitalized version...

$ NODE_TLS_REJECT_UNAUTHORIZED=0 RAILWAY_TOKEN=$RAILWAY_TOKEN npx railway domain --service $capitalizedServiceName || echo "warning emoji Domain creation failed via CLI"

Unauthorized. Please login with railway login

warning emoji Domain creation failed via CLI

$ echo "information_source emoji If domain creation failed, please create manually in Railway dashboard:"

information_source emoji If domain creation failed, please create manually in Railway dashboard:

$ echo " 1. Go to your Railway project dashboard"

1. Go to your Railway project dashboard

$ echo " 2. Click on your service: $capitalizedServiceName"

2. Click on your service: Carpool

$ echo " 3. Go to 'Settings' -> 'Domains'"

3. Go to 'Settings' -> 'Domains'

$ echo " 4. Click 'Generate Domain' or add a custom domain"

4. Click 'Generate Domain' or add a custom domain

$ echo "clipboard emoji Domain setup completed"

clipboard emoji Domain setup completed


Anonymous
PROOP

5 months ago

db error

$ npm install @railway/cli

npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead

added 184 packages, and audited 185 packages in 19s

14 packages are looking for funding

run npm fund for details

1 moderate severity vulnerability

To address all issues, run:

npm audit fix --force

Run npm audit for details.

$ echo "Creating PostgreSQL database via Railway CLI..."

Creating PostgreSQL database via Railway CLI...

$ echo "mag emoji Checking if database already exists..."

mag emoji Checking if database already exists...

$ echo "wrench emoji Attempting database creation with Railway CLI..."

wrench emoji Attempting database creation with Railway CLI...

$ NODE_TLS_REJECT_UNAUTHORIZED=0 RAILWAY_TOKEN=$RAILWAY_TOKEN npx railway add --database postgres --service carpool-db || echo "warning emoji Database creation failed via CLI"

> What do you need? Database

Unauthorized. Please login with railway login

warning emoji Database creation failed via CLI

$ echo "information_source emoji If database creation failed, please create manually in Railway dashboard:"

information_source emoji If database creation failed, please create manually in Railway dashboard:

$ echo " 1. Go to your Railway project dashboard"

1. Go to your Railway project dashboard

$ echo " 2. Click 'New Service' -> 'Database' -> 'PostgreSQL'"

2. Click 'New Service' -> 'Database' -> 'PostgreSQL'

$ echo " 3. Name it: carpool-db"

3. Name it: carpool-db

$ echo "clipboard emoji Database setup completed"

clipboard emoji Database setup completed


Anonymous
PROOP

5 months ago

still got this error

Unauthorized. Please login with `railway login


5 months ago

hey, so I did it and it was fairly simple, just follow these steps:

railway login --browserless

railway link

railway add -> select postgres

railway service -> connect to your existing service created above

railway status / railway variables (--json) if you want to see it in different formats.

youre getting unauthorized, please login with railway login because you arent logged in / not authenticated. you can attempt to do it via browserless. you can easily automate these if you wish via a script

Attachments


yeeet

hey, so I did it and it was fairly simple, just follow these steps:railway login --browserlessrailway linkrailway add -> select postgresrailway service -> connect to your existing service created aboverailway status / railway variables (--json) if you want to see it in different formats.youre getting unauthorized, please login with railway login because you arent logged in / not authenticated. you can attempt to do it via browserless. you can easily automate these if you wish via a script

Anonymous
PROOP

5 months ago

i am using gitlab pipline...

$ railway login --browserless

Cannot login in non-interactive mode

Created fresh repository.

Checking out 2700ed11 as detached HEAD (ref is main)...

Skipping Git submodules setup

Executing "step_script" stage of the job script00:01

$ echo "rocket emoji Starting Railway deployment using official CLI Docker image..."

rocket emoji Starting Railway deployment using official CLI Docker image...

$ echo "mag emoji Using Railway CLI Docker image ghcr.io/railwayapp/cli:latest"

mag emoji Using Railway CLI Docker image ghcr.io/railwayapp/cli:latest

$ echo "mag emoji Service name ${SERVICE_NAME}"

mag emoji Service name CarPool

$ echo "mag emoji App name ${APP_NAME}"

mag emoji App name CarPool

$ echo "# Set up Railway authentication"

# Set up Railway authentication

$ export NODE_TLS_REJECT_UNAUTHORIZED=0

$ export RAILWAY_TOKEN="$RAILWAY_TOKEN"

$ export CI="true"

$ echo "# Check Railway authentication"

# Check Railway authentication

$ echo "RAILWAY_TOKEN is set"

RAILWAY_TOKEN is set

$ echo "Attempting Railway login with browserless mode..."

Attempting Railway login with browserless mode...

$ railway login --browserless

Cannot login in non-interactive mode

Cleaning up project directory and file based variables00:00

ERROR: Job failed: command terminated with exit code 1


5 months ago

youre not passing your account/team's token like specified in railway's docs for a pipeline, RAILWAY_API_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

then your pipeline should work fine if everything else configured correctly.


5 months ago

browserless only works via the CLI - you should really read the docs ive linked


yeeet

youre not passing your account/team's token like specified in railway's docs for a pipeline, RAILWAY_API_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.then your pipeline should work fine if everything else configured correctly.

Anonymous
PROOP

5 months ago

thanks for reply

RAILWAY_TOKEN will read the variable setup in my GItLab CICD which has the correct token and it is already passed.

i actualy already tested all method mentioned in the docs you shared, tested with Railway login, CLI, API, no luck.. thanks.


Loading...