DEV Community

Discussion on: Connecting to db with nodejs

 
brandinchiu profile image
Brandin Chiu

It sounds like you're connecting to server A via ssh, then connecting to server B via ssh, and then connecting to the database from the command line on server B.

If this is true, then this won't be an effective troubleshooting step.

Instead, ssh into server A, and then try to connect to the database server (not the computer it's running on) via the mysql command line on server A.

  • ssh into server A
  • run mysql -h IP_ADDRESS_OF_SERVER_B -u MYSQL_USERNAME -PPASSWORD

Note that there is no space between the -P and the password. A live example might look like: mysql -h 35.123.0.10 -u myUser -PreallySecurePassword123

If you can connect successfully using the above, then your connection details in your code (through your ORM/DB configuration) are wrong.

If you can't connect using the above, then there are network issues like a firewall that is blocking traffic either incoming or outgoing between server A and server B.

Your next step would be to troubleshoot that by reviewing the networking setup of those two machines, using pings or traceroutes as a starting point.

Thread Thread
 
mihranh profile image
MihranH

Yes, it seems the code part has issues. CMD ssh and mysql part were done the way you said and they worked. Thanks a lot and will come back with more questions if needed!