Apache httpd:bind:Address already in use - linux

When I cross compile appache into DM8168,It appears "httpd:bind:Address already in use".I changed the port 80 to any,such as 8080,90...It doesn't work either.Could anyone tell me why?Thanks for your help.

make sure port 80 is not used by any other service or application with netstat command:
netstat -tulpn| grep :80
If port 80 or other port which you assigned (8080,90)is bind to httpd, kill all process:
killall -9 httpd
Now start the httpd:
/etc/init.d/httpd start
Also make sure you are root while starting the httpd service.

Related

NodeJS Pipe 443 already in use

I'm running an https server with pagekite and sometimes this error happens. Can someone explain to me what this is? I can't solve with lsof and kill
Use
netstat -an
in windows or
netstat -tulpn
in Linux to see if port 443 (https://) is taken by a process.

Apache does not start at boot up because of socket binding error but starts manually

Apache server is giving an error at boot up (or when I try to start the service with systemctl manually)
make_sock: could not bind to address [::]:7301 # virtual host port
But it starts nicely with following command:
httpd -k start
3 things come to mind:
That port, 7301 is already in use by another process, try a netstat -apn | grep 7301 to see if that's the case and if so change the apache port or kill that process.
You have 2 conflicting Listen directives in your apache conf file. For ex. Listen *:7301 and Listen 1.2.3.4:7301 would cause that error, pleasr remove one of them
You have configured apache to use an interface which is not active or does not have IPv6 enabled
Edit:
You have selinux active on your host and it's preventing apache from using a non default port as port 80.

Ubuntu: Http-server on port 80 starting up, but can't access from browser?

So I have a web application being run on an http-server via npm. In my package.jsonfile, I have the line "start": "sudo http-server -a [my ip address] -p 8065 -c-1", and my app runs fine when I go to http://myipaddress:8065. However if I change the 8065 to just 80, in the json file (which is what I want), I still get the success message:
Starting up http-server, serving ./
Available on:
http://myipaddress:80
But when I go to the link, chrome givess me an ERR_CONNECTION_REFUSED. Anybody know what's going on?
I would suggest there are three possible problems here.
Port 80 is already in use.
You are not running the application as root (you can't bind to ports <1024 if you are not root)
http-server isn't binding correctly
To check if port 80 is already in use try
netstat -lntu | grep :80
If port 80 is already in use you should see something like
tcp6 0 0 :::80 :::* LISTEN
You will need to close whatever is running on port 80 (apache? nginx?)
To check if you can actually bind to port 80, try running http-server from the console rather than via npm i.e.
sudo http-server -a [my ip address] -p 80 -c-1
If the above works you should be able to run npm as root to start your http-server i.e.
sudo npm start
You may need to remove sudo from your package.json:
"start": "http-server -a [my ip address] -p 8065 -c-1"
We need to make sure that http-server is working correctly on your system. We will test it with w3m a console based web browser.
You may need to install w3m with sudo apt-get install w3m if you do not have it already.
create a new directory. mkdir /tmp/testing
CD into new dir cd /tmp/testing
Start http-server with `http-server . -a localhost -p 1234
Visit http://localhost:1234 with w3m w3m http://localhost:1234/
Start http-server with `http-server . -a localhost -p 80
Visit http://localhost in a w3m w3m http://localhost/ does it work?
Quick tests:
Try to access this on as the localhost address, either localhost or 127.0.0.1 to shortcut any potential firewalls.
Try to telnet to this address on port 80 to see what the server replies (if any).
Do you have Apache installed? Are sure putting your application server on port 80 is not in conflict with Apache?
In that case it is better to redirect port 80 to your application server that just starting it on the Apache port.
Is it error 102? Check this link. Probably it's caused by some extensions you installed.
To run nodejs apps with pot less than 1000 you need a root access. Use sudo node app.js Also dont forget to open firewall. And make sure nobody else listening on port 80.

Node Error: EADDRINUSE, how do I find out what process is locking this address?

I have a test app using express that crashes on server.listen(80): ERROR: listen EADDRINUSE. I tried to kill all node processes with killall -9 node but there were no processes. I also have apache running on the same server but I've got two IPs and I have configured apache to serve only one of them and yesterday everything worked fine. Some process is blocking port 80 on IP reserved for node and it's not node. What should I do?
UPDATE
That was my own lame mistake. I defined node_ip and node_port but accidently omitted node_ip in server.listen.
You could use
lsof -i :80
to see what process is running on that port.
if you want to see it first, you can use netstat, e.g.
netstat -tulpn | grep 80
You can use tcpkill ie.:
tcpkill -i eth0 port 80

netstat commands to run on unix server, what commands should I use for my use-case and why?

Sorry in advance for such a noob question, but I'm certainly a noob.
My question is what does it mean to LISTEN or ACCEPT on a port as it relates to my example?
EXAMPLE:
I have a tomcat server, and It will use port 8080. I want to make sure that port is available for me to use.
What commands should I perform on my unix server and why?
what information would a command like this give me: netstat -an | grep LISTEN
If a port shows up as LISTEN in netstat, it means the port is in use by a server process, so you can't use it. Here is an example:
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
which shows that port 631 is in use.
Ignore the UNIX type sockets at the end - they are irrelevant.
For checking port 8080 is in use or not, you can simply use the command netstat -an|grep 8080. If you get an output in below format, that means 8080 is already in use and you need to assign a new port for the tomcat.
# netstat -an
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN
Netstat command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc,
a option with netstat will give you both listening and non listening ports
n option when you don’t want the name of the host, port or user to be displayed, use netstat -n option. This will display in numbers, instead of resolving the host name, port name, user name. This also speeds up the output, as netstat is not performing any look-up.
For more understand the use of netstat command here are its options:
-a : All ports
-t : Ports TCP
-u : Ports UDP
-l : Listening ports
-n : IP address without domain name resolution
-p : Name of the program and it associated PID
So:
-To display all port (TCP & UDP), PId with the associated name of the program :
$ netstat -paunt
-To display all Listening ports (TCP), PId with the associated name of the program : (and we can also filter with the grep command)
$ sudo netstat -plnt | grep ':80'
I hope it will be helpful :)
You can also use telnet to check if the port is open and listening e.g,
Zeeshan$ telnet google.com 80
Trying 173.194.35.5...
Connected to google.com.
Escape character is '^]'.
I am telnetting google.com on port 80. If you see the third line in the output, you will notice it says it is connected with the Google's web server. The same way you have a JAVA application server called Tomcat and it is listening on port 8080. In fact it is asking clients to connect to it on port 8080 so it can give away the JAVA services to client. When I will use from a client side telnet localhost 8080 I will be connected the same way I have connected with Google's web server on port 80. Provided that Tomcat is running and listening on port 8080. If port 8080 is not free and occupied by some other application you can simply change the port 8080 to another free port. Telnet should give you the following status:
accepted (connected), refused, and timeout
connection refused - nothing is running on that port
accepted - some application is running on the port
timeout - a firewall is blocking access
So now there are two possible ways to check. From the same machine you are running Tomcat server:
telnet localhost 8080
Of if you want to check it from some other machine or outside of the network:
telnet 192.168.1.1 8080
I hope that helps.
use can also run the below command, it will list the Port and corresponding PID, if any process is using those ports
netstat -tulpn

Resources