2 years ago
Every time I deploy my project, I always get this error. I checked everything including env variables but still no good. Has anyone encountered this issue before? I'm deploying restful api using java Spring boot
43 Replies
2 years ago
Hey, i'm going to need more context here, what kind of connection is timing out exactly?
2 years ago
Connection to the server. It seems that when I deploy the project, the server connection is not successful. Just a hunch this could be something with the host and the port. But can you tell me more about this, hopefully, you could help me
2 years ago
From the surrounding logs that's connection refused to the MySQL database, please make sure you are using all the correct credentials for the database and they are in the format that the MySQL client expects.
2 years ago
This my value spring.datasource.url:
DB_HOST: 172.31.16.1
DB_PORT: 3306
DB_NAME: newdb
jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}
2 years ago
Can you tell me where should I get the right value for the host?
2 years ago
Where is 172.31.16.1 coming from, because that's a local address, where is your database hosted?
2 years ago
I don't where my database is hosted. And the value 172.31.16.1 is the value from IP4 under Ethernet adapter
2 years ago
I mean how do i find where my database is hosted?
2 years ago
Is that support to be a separate deployment? Or together with my project?
2 years ago
It would be a separate Railway service within the same Railway project, can I take that as you don't have MySQL deployed to Railway?
2 years ago
Yeah I don't have have mysql deployed in railway
2 years ago
Go ahead and do that from within the Create menu at the top right of the project canvas.
2 years ago
I'm in the middle of configuring mysql service, Can I ask if i need to change values in the enviroment variables before deploying it?
2 years ago
Got it thanks
2 years ago
I deployed mysql database.
Status changed to Solved Railway • over 1 year ago
2 years ago
On it
2 years ago
With my deployed mysql service, I checked the logs and I see some highlights on it. Can this cause any issues?
Attachments
2 years ago
Please keep in mind red does not always mean an error, you should consider the contents of the logs to determine if something is an error or not.
2 years ago
I see. Just checking
2 years ago
Hi again. This is my screenshot for my deployment of my project. There are no errors. Does this mean it's good?
Attachments
2 years ago
It's just that when I make a fetch to the url I get error for 502 Bad Gateway
2 years ago
Here's a sample
2 years ago
It says 502 bad request
2 years ago
I see. how to find the url for my restful api request in my deployed project?
2 years ago
This is what happens when I use the link found under the service settings. However, there seems to be no error on deploy logs
Attachments
2 years ago
I checked that article it's giving me any hints on how to solve this issue
2 years ago
Should I create a Port Variable with a value on it?
2 years ago
The docs page goes over what fundamentally needs to be done to fix this issue, you do not need to set a port variable, but your app needs to listen on it.
Please carefully read the docs page.
2 years ago
I fixed it, I simply have to add another property in application.properties:
server.port={DB_PORT}
2 years ago
Thank you so much. You are an amazing help. Without your help, I will never make any success with this project.

