I had been battling with this particular issue for a while on my virtual machine running uBuntu 8.04 Hardy Heron. Basically it was a straight through install of 8.04, after which I installed lampp for PHP, mySQL, and FTP services so that I could host a couple of websites on this virtual machine.
At first everything was running 100% I hadn’t changed the default FTP server configuration that appeared to be working out of the box from the base install. Then one day I decided I wanted to play around with some settings and ended up somehow removing my FTP server – not entirely though as something was continuing to hold port 21 up and not allow me to use any other FTP server that used port 21.
What I did was I configured proftpd which seems to have come along with my install of lampp (Also known as xampp). I configured my users, IP address and all other details, but I was still getting problems when trying to connect via FTP from another PC on the local network.
Trying to start proftpd from the command line sudo /etc/init.d/proftpd start
would result in the service appearing to start, but it wouldn’t actually be running. I confirmed this by opening the gproftpd GUI from System – Administration – GPROFTPD. The status at the top right of the GUI would say “Deactivated”
A very helpful user on the ubuntu forums also showed me a useful debug command that helped me identify my problem.
From the terminal, type:
sudo proftpd -nd6
This apparently starts proftpd in debug level 6.
It gives you a bunch of diagnostic information, and on the last line I spotted my problem:
Failed binding to ::, port 21: Address already in use
So, something else was already using port 21. Obviously my old FTP server’s remnants somewhere. Now to figure out what was using it.
sudo netstat -anp --tcp --udp | grep LISTEN
From that command, I found a line with :21 in it (indicating port 21) and at the end of the line, I found the process name and process ID number. The process in my case was inetd.
Now I went to see what the inetd.conf file had in it in terms of configuration:
sudo nano /etc/inetd.conf
This loads the nano text editor and displays the contents of the file. I had :
ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.ftpd
I made a copy of this inetd.conf file as a backup, and then deleted that entire line, as that was obviously what was holding port 21. Ctrl-X exits the editor, and I chose to press “Y” to save changes.
Now I needed to kill and restart the inetd process. I used :
sudo killall -HUP inetd
This kills the process, and allows inetd to restart and reload the inetd.conf file.
I went back to my proftpd.conf file and ensured it was setup to use port 21 for FTP connections, then restarted the proftpd service with :
sudo /etc/init.d/proftpd stop
sudo /etc/init.d/proftpd start
Then finally I went back to my other PC, and retried the FTP connection using FileZilla FTP client, and finally got connected! I hope this helps anyone with similar issues, as I had to use multiple sources to try and figure out what was causing this and where.
Hi Tad,
No problem at all – glad it could provide some useful information! Interesting situation regarding your machine picking up a DHCP address after having switched to a static IP… the logic definitely points to your LAMP install if that is the only difference between the machines. I’ll see if I can emulate this next time I do a lamp install on one of my VMs!
Thanks for the good info!
I use Hardy for little servers for this and that and it seems that the out-of-the-box config you get with apt leaves a few stray bits strewn about that need to be cleaned up by hand.
My most recent problem was in setting a static IP address: It worked fine for a day or so, then my machine apparently disappeared. A bit of investigation revealed that somehow I still had DHCP running—maybe it came along for the ride in the LAMP install.
I did a “sudo apt-get remove dhcp3-client” and the problem was solved.
It’s a mystery why my other Hardy Heron servers don’t have the same problem; I did not choose LAMP for them, so that might be it.
Hi Doron,
I am glad this helped you resolve your problem! I have since set up a few more instances of proftpd on some other ubuntu servers so I am kind of getting the hang of it now…
Cheers,
Sean
I had the same problem. I am new to linux, so this hit the spot. May you live 1000 years!