GuitarTater
Posts: 3
Joined: Sat Aug 18, 2012 5:12 pm
Location: Nottinghamshire, UK.

Hostname web server problem

Mon Aug 20, 2012 1:06 pm

Hi
I'm new to this forum so this is probably the wrong place (sorry :( )

I'm looking to set up a little web server on my home network for website development and so I can teach myself a little bit about web hosting and how to optimise sites etc...

The problem I have at the minute is connecting using the hostname of the raspberry pi. There's a couple of tutorials I have followed that are basically the same steps.

I've enabled SSH and I can use PuTTY to remotely control the Pi but only using the local IP address 192.168.xxx.xxx
I've tried to change the hostname by editing /etc/hosts and /etc/hostname, as well as just hostname xxxxxxxx

For some reason I can't connect to it with the new hostname (or the old one), have I made an error in the Pi side of things or is it likely to be a router problem?

Any help would be greatly appreciated
Thanks :)

The tutorials I used are http://tinkernut.com/wiki/page/Episode_320 and http://www.instructables.com/id/Raspber ... /?ALLSTEPS

User avatar
M.M
Posts: 107
Joined: Fri Aug 03, 2012 7:40 am
Location: Hamburg, GER

Re: Hostname web server problem

Mon Aug 20, 2012 2:33 pm

Hi GuitarTater,

could you recheck if your hostname is configured correctly by just typing "hostname" in a terminal?

Did you use spaces? If you did, I think your hostname will be cut off at the first space.

If the shown hostname is correct, you can be sure that the RasPi itself knows its name ;)

But to connect to it, the machine you use to establish your ssh session needs to be able to match the name to an IP address, too.

Since you use PuTTy I am guessing you are using Windows?

So, could you please open a cmd window and check if your computer can reach your Pi by its hostname by executing "ping <hostname>"?

This should narrow down were we would have to look for the problem.

Regards
"If people read the FAQs the Qs wouldn't be A F, would they?"

GuitarTater
Posts: 3
Joined: Sat Aug 18, 2012 5:12 pm
Location: Nottinghamshire, UK.

Re: Hostname web server problem

Mon Aug 20, 2012 6:52 pm

Hi M.M
Thanks for your response :)

The Pi appears to know it's own name when type hostname in the terminal. Yes I'm using Windows, pinging the hostname doesn't work it just says "ping request could not find host xxxx".

I have noticed that when I login to the Pi, when it asks for the password it says enter Password for [email protected] (the ip address of the Pi), but when i've logged in the terminal says [email protected]"hostname" (the hostname I set). Is this normal?

Thanks again

User avatar
nroff-man
Posts: 23
Joined: Mon Jul 30, 2012 7:31 pm
Location: /usr/bin

Re: Hostname web server problem

Mon Aug 20, 2012 8:24 pm

LO

You need to edit the hosts file on the machine you are
connecting *from* since this is where the name is looked
up prior to creating a connexion to the RPI.

See: http://en.wikipedia.org/wiki/Hosts_%28file%29

bye

User avatar
M.M
Posts: 107
Joined: Fri Aug 03, 2012 7:40 am
Location: Hamburg, GER

Re: Hostname web server problem

Mon Aug 20, 2012 9:06 pm

EDIT: nroff-man was faster but, nevertheless... :D

Hi GuitarTater,

ok, so apparently your Windows machine doesn't know your Pi's name.

There is a "quick-and-dirty" fix for that. If your Pi's IP address does not change very often and you are not interested in setting up a whole nameserver and such, this might be what you need:

Assuming you use Windows 7
- Go to the Start menu and find Notepad (or any file editor you like)
- Right click on it and choose "Run as Administrator"
- Open the file C:\Windows\system32\drivers\etc\hosts
- Insert IP and name of the Pi like shown in the examples within the file
- Save it and you are done :)

If the file does not show, it is possible that your folders are set to making hidden files invisible. You can make them visible again by pressing WINDOWS KEY + E taking you to the Windows Explorer and then hitting the ALT key to access the menu bar. Navigate to "Tools -> Folder Options" and in the paragraph about "Hidden files and folder" select "Show hidden files and folders". Now you should be able to access the file as described above.


Regards
"If people read the FAQs the Qs wouldn't be A F, would they?"

GuitarTater
Posts: 3
Joined: Sat Aug 18, 2012 5:12 pm
Location: Nottinghamshire, UK.

Re: Hostname web server problem

Tue Aug 21, 2012 11:36 am

Thanks :) That's now worked

Return to “Beginners”