22 days 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
12 Replies
22 days 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!
22 days 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?
22 days ago
monuit
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
22 days 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.
21 days ago
Trying domain creation for service: Carpool
$ echo "
Attempting domain creation with Railway CLI..."
Attempting domain creation with Railway CLI...
$ NODE_TLS_REJECT_UNAUTHORIZED=0 RAILWAY_TOKEN=$RAILWAY_TOKEN npx railway domain --service CarPool || echo "
Domain creation failed for service 'CarPool', trying capitalized version..."
Unauthorized. Please login with railway login
Domain creation failed for service 'CarPool', trying capitalized version...
$ NODE_TLS_REJECT_UNAUTHORIZED=0 RAILWAY_TOKEN=$RAILWAY_TOKEN npx railway domain --service $capitalizedServiceName || echo "
Domain creation failed via CLI"
Unauthorized. Please login with railway login
Domain creation failed via CLI
$ echo "
If domain creation failed, please create manually in Railway dashboard:"
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 "
Domain setup completed"
Domain setup completed
21 days 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 "
Checking if database already exists..."
Checking if database already exists...
$ echo "
Attempting database creation with Railway CLI..."
Attempting database creation with Railway CLI...
$ NODE_TLS_REJECT_UNAUTHORIZED=0 RAILWAY_TOKEN=$RAILWAY_TOKEN npx railway add --database postgres --service carpool-db || echo "
Database creation failed via CLI"
> What do you need? Database
Unauthorized. Please login with railway login
Database creation failed via CLI
$ echo "
If database creation failed, please create manually in Railway dashboard:"
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 "
Database setup completed"
Database setup completed
21 days ago
still got this error
Unauthorized. Please login with `railway login
21 days 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
monuit
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
21 days 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 "
Starting Railway deployment using official CLI Docker image..."
Starting Railway deployment using official CLI Docker image...
$ echo "
Using Railway CLI Docker image ghcr.io/railwayapp/cli:latest"
Using Railway CLI Docker image ghcr.io/railwayapp/cli:latest
$ echo "
Service name ${SERVICE_NAME}"
Service name CarPool
$ echo "
App name ${APP_NAME}"
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
21 days 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.
21 days ago
browserless only works via the CLI - you should really read the docs ive linked
monuit
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.
21 days 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.