Quote
I have been trying to create a client-server program ... that is able to access a remote database
Where you not
given a server to communicate with?
Or is this something you're doing for yourself (well done, if that's the case!)
You
can use your own computer as the server, as long as you're happy for it to be switched on and for the database to be running and exposed through your local Firewall at any time that anyone [else] wants to use it.
Quote
... I used localhost on the default port ...
"localhost" is just a convenient "alias" for your computer, which has another, "real" name. Try connecting to that "real" name instead of localhost.
Regards, Phill W.