10 months ago
I need to connect my app to a Google Cloud SQL instance. But since railway doesn't have static IP addresses I can't create the network address needed it has been suggested that I install the proxy service via a docker image. They even gave me a dockerFile to do so. but I'm not really sure how to do this in railway. do I just add this to my apps repo? (app was working fine connected to the test database so I want to minimize any code changes if possible) do I have to create a new repo and create a empty service in my project, point it to the new repo and connect to it from my app service? Any guidance on this would be appreciated. ```FROM ubuntu:latest
# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
unzip \
wget
# Download and install the Cloud SQL Auth Proxy
RUN wget -nv https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64.zip \
&& unzip cloud_sql_proxy.linux.amd64.zip \
&& mv cloud_sql_proxy /usr/local/bin/
# Set up the proxy configuration
ENV CLOUD_SQL_PROXY_CONFIG=/etc/cloud_sql_proxy.conf
# Create the configuration file
RUN echo "mysql:tcp:your-project-id:your-region:your-instance-name=tcp:127.0.0.1:3306" > $CLOUD_SQL_PROXY_CONFIG
# Start the proxy
CMD ["/usr/local/bin/cloud_sql_proxy", "-dir=/etc/cloud_sql_proxy.conf", "-log_level=debug"]
```
6 Replies
10 months ago
I really can't recommend you proceed with trying to use a proxy like that, Railway does support static outbound IPs on the Pro plan.
10 months ago
Any idea where I can find info on that?
10 months ago
Don't know if it's in the docs, but once on the Pro plan you just enable it in your service settings.
10 months ago
Still not connecting to the database but I'm not really sure what the problem is.
10 months ago
Please make sure you are whitelisting the correct IP as given in the service settings and make sure you have all your connection details correct
10 months ago
Can you elaborate on what you mean by "not connecting"? Are you seeing any errors, and if so, what?
It'd be great if you could provide logs as well.