Enter website through IP and not domain

How can I enter a dev website on my linode only through the IP adress and not the domain which don't point to Linode yet?

I have tried - 1.2.3.4/srv/www/domain with no luck.

[1.2.3.4 - Is my IP]

7 Replies

I do it by pointing my computers hosts file to the dev ip- for me it is /etc/hosts - win uses something like c:\windows\system32\drivers\etc\hosts

@bryantrv:

I do it by pointing my computers hosts file to the dev ip- for me it is /etc/hosts - win uses something like c:\windows\system32\drivers\etc\hosts

How do I do it? What are the commands?

If you're using Windows, run Notepad (or a text editor) as Administrator (Windows Vista or 7 - for XP, it's not necessary), and open the file C:\WINDOWS\system32\drivers\etc\hosts (no file extension, and assuming that C:\WINDOWS is your Windows install folder).

If you're using Linux, use your favorite text editor and open the file /etc/hosts.

If you're using Mac OS X, see this article: Mac OS X: How to Add Hosts to Local Hosts File

When you have your hosts file open, add the following line (replace my examples with your Linode's IP and your domain name):

1.2.3.4       example.com www.example.com

It doesn't matter how many spaces you have between each of these "words", or if you're using the key, as long as there's some whitespace between them.

Just to add to what NeonNero said…

On Windows, if the hosts file does not exist, create it.

On Windows in Notepad when saving the file, put the filename in quotes -- like "hosts" -- to prevent Windows from automatically adding a .txt extension.

hosts.txt will not work, the file must be named hosts with no extension.

@NeonNero:

If you're using Mac OS X, see this article: Mac OS X: How to Add Hosts to Local Hosts File

When you have your hosts file open, add the following line (replace my examples with your Linode's IP and your domain name):

1.2.3.4       example.com www.example.com

It doesn't matter how many spaces you have between each of these "words", or if you're using the key, as long as there's some whitespace between them.

I a mac user - The link isn't working but I have edit my local /etc/hosts file and add this follow line:

1.2.3.4 domain.com domain [with the correct details].

I added the linode IP.

Nothing happens when entering this IP in the browser.

What am I missing here?

Forgot sudo…

Working now…

Thank you…

I keep the required lines in my hosts file and just #comment them out when needed .

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