Rails Deployment - SSH to Domain instead of IP

I’m running my Rails application on an Ubuntu 18.04 server. I purchased a domain for my server and I’m able to reach my website on this domain without problems - so my droplet configuration worked perfectly.

Now I want to change my Capistrano-Config to use the domain instead of the IP-address for deployment, but I can’t SSH on the VPS by using the domain name.

So if I try: ssh deploy@ip-address it works, but if I do ssh I get the connection error: ssh: connect to host port 22: Connection timed out

Shouldn’t the DNS-Server map my domain name to the IP-address? I read in some threads that I should edit the /etc/hosts file, but some others say it’s not good practice.

What am I missing? I’m relatively new to this topic, so maybe someone can give me a good hint?

Thanks in advance!

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @rickeeey

In order to ssh to your droplet using a domain name or hostname in short you need to make sure that the domain is pointed/resolving from the server itself.

You can check if the current hostname is resolving/pointed to your droplet. You can also point any domain name to your droplet and use this as hostname when trying to ssh. It will work for you same as using the IP address.

If you want to access your server easily instead of typing or trying to find the droplet IP address, you can simply create an alias on your local machine as well.

Hope this helps.

Regards, Alex