Rails Deployment - SSH to Domain instead of IP

November 18, 2019 205 views
Ruby on Rails Nginx Deployment Initial Server Setup

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 deploy@example.de I get the connection error: ssh: connect to host example.de 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!

1 Answer

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

Have another answer? Share your knowledge.