0

I have 2 cloud sql server ( dev and qa) , How to do port forwarding for both sql server to 1 cloud proxy vm. I did port forwarding for dev sql server long back and its listening on 1433 in cloud proxy vm.

sudo iptables -t nat -I PREROUTING -p tcp --dport 1433 -j DNAT --to-destination 127.0.0.1:1433
sudo nohup ./cloud_sql_proxy -instances=project:region:dev-sqlserver=tcp:1433 

Now i have another qa sql server which i want to do port forwarding in same cloud proxy vm.

I want the way to do port forwarding for both sql server in same cloud proxy vm.

James Z
12.3k10 gold badges27 silver badges50 bronze badges
asked Feb 21, 2024 at 13:45

1 Answer 1

1

The Cloud SQL Proxy supports multiple instances. As per documentation:

./cloud-sql-proxy --port 6000 <INSTANCE_CONNECTION_NAME_1> <INSTANCE_CONNECTION_NAME_2>

Consider migrating to v2, follow the Migration Guide.

answered Feb 22, 2024 at 19:41
Sign up to request clarification or add additional context in comments.

2 Comments

but in case of both db are sql server then how to use their port as sqlserver is running is 1433 only
Once you start the Proxy, the logs will tell you which IP address and port to use for each SQL Server. Example: $ ./cloud-sql-proxy <INSTANCE_CONNECTION_NAME_1> <INSTANCE_CONNECTION_NAME_2> Authorizing with Application Default Credentials [INSTANCE_CONNECTION_NAME_1] Listening on 127.0.0.1:1433 [INSTANCE_CONNECTION_NAME_2] Listening on 127.0.0.1:1434 The proxy has started successfully and is ready for new connections! You can specify the IP address and port as per documentation

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.