✓ Solved

Instance IP address gets resolved to localhost, refuses con connect.

I have deployed a cPanel marketplace application to a Nanode instance. When trying to access to my cPanel login (at port 2083, through IPV4:2083), my browser resolves the IP address as localhost, (as localhost:2083) and states that "localhost refused to connect".

I'm almost certain that the problem stems from my /etc/hosts file, but I cannot seem to find the issue. I've been using this answer to guide the way in which I've written it, together with this Linode guide.

# /etc/hosts
127.0.0.1               localhost       <custom_hostname>
<IPV4>   <my_domain.com> <www.my_domain.com> 

# The following lines are desirable for IPv6 capable hosts
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
<IPV4>           <IPV4>.cprapid.com <IPV4>

I also have 2 A records for my my_domain.com as well as the www subdomain and both are associated to the instance IP. The instance's rDNS as been set to the correct my_domain.com.

So far I have changed the hosts file in different ways, and I've deactivated the ufw firewall.

What could be the cause of this issue?

2 Replies

✓ Best Answer

I'm not 100% sure that you should be adding your Linode's custom hostname to the top entry that defines your localhost though I do see how the guide would be confusing. My guess is that your domain entry behind localhost might be causing your resolution issues. As far as I have always done my config (even for multiple domains/sub-domains), I would try:

127.0.0.1   localhost
$IPADDRESS  $SUBDMAIN.DOMAIN.COM    $DOMAIN.COM     $SUBDOMAIN (or hostname)
$IPADDRESS  $SUBDOMAIN2.DOMAIN.COM  $DOMAIN.COM     $SUBDMAIN2

Please keep in mind that some of that formatting/organizing is my own personal preference. As I understand it, the main thing would be to remove any additional entries on your localhost line before trying again.

@jhartman, your suggestion solved my issue. Out of curiosity, why would my setup would cause a resolution issue?

Thank you very much!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct