Connect Timed Out
karlarboiz
HOBBYOP

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

Solved

43 Replies

2 years ago

Hey, i'm going to need more context here, what kind of connection is timing out exactly?


karlarboiz
HOBBYOP

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


karlarboiz
HOBBYOP

2 years ago

This is how it looks like in the deploy logs

Attachments


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.


karlarboiz
HOBBYOP

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}


karlarboiz
HOBBYOP

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?


karlarboiz
HOBBYOP

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


karlarboiz
HOBBYOP

2 years ago

I mean how do i find where my database is hosted?


2 years ago

Do you have a MySQL database deployed to Railway?


karlarboiz
HOBBYOP

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?


karlarboiz
HOBBYOP

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.


karlarboiz
HOBBYOP

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

No, that would be done after deploying.


karlarboiz
HOBBYOP

2 years ago

Got it thanks


karlarboiz
HOBBYOP

2 years ago

I deployed mysql database.


2 years ago

Use its variables to configure your MySQL client in code.


Status changed to Solved Railway over 1 year ago


karlarboiz
HOBBYOP

2 years ago

On it


karlarboiz
HOBBYOP

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.


karlarboiz
HOBBYOP

2 years ago

I see. Just checking


karlarboiz
HOBBYOP

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

Supposedly, does your app work as intended?


karlarboiz
HOBBYOP

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

What error logs do you get?


karlarboiz
HOBBYOP

2 years ago

Here's a sample


karlarboiz
HOBBYOP

2 years ago

Here's the screenshot


karlarboiz
HOBBYOP

2 years ago

Sorry. Here it is


karlarboiz
HOBBYOP

2 years ago

Here it is

Attachments


2 years ago

I'm not seeing any errors in those logs.


karlarboiz
HOBBYOP

2 years ago

It says 502 bad request


2 years ago

I'm sorry but that does not provide enough information.


karlarboiz
HOBBYOP

2 years ago

I see. how to find the url for my restful api request in my deployed project?


2 years ago

That is found within the service settings.


karlarboiz
HOBBYOP

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


karlarboiz
HOBBYOP

2 years ago

I checked that article it's giving me any hints on how to solve this issue


karlarboiz
HOBBYOP

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.


karlarboiz
HOBBYOP

2 years ago

I fixed it, I simply have to add another property in application.properties:

server.port={DB_PORT}


karlarboiz
HOBBYOP

2 years ago

Thank you so much. You are an amazing help. Without your help, I will never make any success with this project.


Loading...