I can't deploy my application
nhatminhgit
FREEOP

10 months ago

When Deploying my application was completed , I open the link to (https://amusing-adaptation-production.up.railway.app/) but it is a bad gateway 502.
Can someone help solve this problem ?

51 Replies

smoothcubegit
HOBBY

10 months ago

Can you type N/A or your project ID
Else this will be closed automatically by @Percy


nhatminhgit
FREEOP

10 months ago

MySQL-8daA


nhatminhgit
FREEOP

10 months ago

N/A


smoothcubegit
HOBBY

10 months ago

can you share the deployment logs?


nhatminhgit
FREEOP

10 months ago

Mounting volume on: /var/lib/containers/railwayapp/bind-mounts/5d5e3f28-b1ae-4059-8080-89521d502fdb/vol_tjr5lr8ublg0xs8w

Starting Container

2025-05-05 08:09:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.3.0-1.el9 started.

2025-05-05 08:09:27+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'

2025-05-05 08:09:27+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.3.0-1.el9 started.

'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'

2025-05-05T08:09:28.650305Z 0 [System] [MY-015015] [Server] MySQL Server - start.

2025-05-05T08:09:28.786758Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 9.3.0) starting as process 1

2025-05-05T08:09:28.794878Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

2025-05-05T08:09:29.949931Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

2025-05-05T08:09:31.016432Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2025-05-05T08:09:31.016487Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.

2025-05-05T08:09:31.022240Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.

2025-05-05T08:09:31.065971Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock

2025-05-05T08:09:31.066089Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '9.3.0' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.


smoothcubegit
HOBBY

10 months ago

are there any more logs that you could share?


nhatminhgit
FREEOP

10 months ago


smoothcubegit
HOBBY

10 months ago

The root of your crash: An infinite restart loop
Your app is repeatedly restarting:

Starting FashionWebApplication v0.0.1-SNAPSHOT using Java 17.0.7 with PID 1 ...

This exact log appears twice within ~30 seconds, and nothing indicates clean shutdown or startup success. That means:
Your Spring Boot app starts, logs a bunch of info, Then crashes silently.
Railway restarts it automatically, which creates the illusion of a "crash loop" with no obvious error.
.


smoothcubegit
HOBBY

10 months ago

To debug you can…

Set logging.level.root=DEBUG in your application.properties

Add --debug to your Spring Boot startup command


smoothcubegit
HOBBY

10 months ago

This means…

Set server.port=${PORT} in your application.properties
Double-check DB connection values (use Railway's environment variables)

Enable debug logging for more output:

logging.level.root=DEBUG
spring.main.banner-mode=log

If possible, run the .jar locally with the same environment to reproduce the crash.


smoothcubegit
HOBBY

10 months ago

Does this make sense? Or do you need clarification?
If it doesn't work you can message back!


nhatminhgit
FREEOP

10 months ago

Thank you very much


nhatminhgit
FREEOP

10 months ago

@OctoCubee I still encounter this error even though I have set server.port=${8080} and logging.level.root=DEBUG spring.main.banner-mode=log

1368892841601794000


nhatminhgit
FREEOP

10 months ago

and I also ran to check my .jar successfully


smoothcubegit
HOBBY

10 months ago

The message that shows up means that there's an issue in your code on deploy. Do you have any code that could be causing this?


nhatminhgit
FREEOP

10 months ago

I don't know because my code seem run fine


smoothcubegit
HOBBY

10 months ago

You might need to add logging in your code for deploy so we can workout what the issue is


nhatminhgit
FREEOP

10 months ago

Okay let me do that, thank you <:salute:1137099685417451530>


nhatminhgit
FREEOP

10 months ago

@OctoCubee oh I got this email

1368898525542219800


nhatminhgit
FREEOP

10 months ago

My account still have memory


smoothcubegit
HOBBY

10 months ago

are you using the trial plan?


nhatminhgit
FREEOP

10 months ago

yes


smoothcubegit
HOBBY

10 months ago

your "amusing adaption" doesnt have enough memory


smoothcubegit
HOBBY

10 months ago

can you go to the metrics for it?


smoothcubegit
HOBBY

10 months ago

example

1368898981345759200


nhatminhgit
FREEOP

10 months ago

1368899019111403500


smoothcubegit
HOBBY

10 months ago

You seem to peak to the very top when you start the deployment


smoothcubegit
HOBBY

10 months ago

Im not too sure sorry, you need to add logging and look through your code to see where it could crash


nhatminhgit
FREEOP

10 months ago

Okay thank you


nhatminhgit
FREEOP

10 months ago

@OctoCubee May you teach me how to log ? I am so confused rn


smoothcubegit
HOBBY

10 months ago

I don't have any detail on what language you're using and other things


nhatminhgit
FREEOP

10 months ago

I use java with spring boot and html, css and js and also I store pics on cloudinary


smoothcubegit
HOBBY

10 months ago

okay, to log you can do > System.out.println("This is a log message.");


nhatminhgit
FREEOP

10 months ago

@OctoCubee Excuse me but is it possible to have error here ?

1368902596760178700


smoothcubegit
HOBBY

10 months ago

I would say to use the generated domain rather than TCP, so yes probably some sort of error xD


nhatminhgit
FREEOP

10 months ago

spring.application.name=Fashion_Web
server.port=${PORT:8080}

Railway database

spring.datasource.url=jdbc:mariadb://turntable.proxy.rlwy.net:59479/railway?useSSL=false
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.mvc.view.prefix=classpath:/templates/
spring.mvc.view.suffix=.html

Bạn có thể giữ lại cấu hình database local (đã comment) để dễ dàng chuyển đổi khi cần

#Local database

spring.datasource.url=jdbc:mariadb://localhost:3306/fashionshop?useSSL=false

spring.messages.encoding=UTF-8
server.servlet.encoding.force=true
server.servlet.encoding.charset=UTF-8

logging.level.org.hibernate.SQL=debug
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace

Chat bot api

gemini.api.key=
qdrant.url=http://localhost:6333

Cloudinary api

cloudinary.cloudname=dgtfqxgvx cloudinary.apikey=
cloudinary.api_secret=
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB

C?u hình Elasticsearch

spring.elasticsearch.rest.uris=https://my-elasticsearch-project-ada03b.es.us-east-1.aws.elastic.cloud:443

spring.elasticsearch.rest.username= # N?u Elasticsearch có authentication

logging.level.root=DEBUG
spring.main.banner-mode=log

here is my application.properties


nhatminhgit
FREEOP

10 months ago

Do I config it correctly ?


smoothcubegit
HOBBY

10 months ago

warning! You've shared some sensitive credentials!!

passwords etc


nhatminhgit
FREEOP

10 months ago

I deleted other key


smoothcubegit
HOBBY

10 months ago

amazing!


smoothcubegit
HOBBY

10 months ago

okay a few things i can see


smoothcubegit
HOBBY

10 months ago

spring.datasource.url=jdbc:mariadb://turntable.proxy.rlwy.net:59479/railway?useSSL=false

Railway uses SSL by itself


smoothcubegit
HOBBY

10 months ago

so you can set it to true


smoothcubegit
HOBBY

10 months ago

Your application.properties file is mostly correct, but to make it more secure and flexible, you should move sensitive information like database passwords and API keys to environment variables, ensure only one database configuration is active at a time (comment the other), and consider using separate configuration profiles (e.g., application-dev.properties and application-prod.properties) to easily switch between local and production environments.


nhatminhgit
FREEOP

10 months ago

Thanks for the advices ❤️


smoothcubegit
HOBBY

10 months ago

Mysql isnt that well known to me, so you can always use AI to debug and hopefully fix it :)


nhatminhgit
FREEOP

10 months ago

@OctoCubee Please excuse but is this cause 502 error ?

1368912532303118600


smoothcubegit
HOBBY

10 months ago

Im sorry, I cannot assist any further


nhatminhgit
FREEOP

10 months ago

@OctoCubee Once again, thanks for your help <:salute:1137099685417451530> . Last night I deployed it successfully.


smoothcubegit
HOBBY

10 months ago

No problemo!


10 months ago

thanks @OctoCubee <:salute:1137099685417451530>


Loading...