Starting a service which may have port conflicts with existing service - mysql

Is there any way to start a service and force a service that is already running to stop if it uses the port that the service I want to start is going to be using?
I'm going to be installing apache and mysql, and want the services to be running without having to manually stopping existing services that use port 80/3306 such as existing apache/mysql services.
I'm using NSIS to make my installer.

To find the process listening on port 80 perhaps you could do the equivilent of this from the command line:
c:\>netstat -aon | findstr 0.0:80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3488
3488 is the process id. Not sure what APIs netstat is using though.
Without disabling or reconfiguring the service that is already using the desired port is still going to cause problems on system restart. The best bet might be to abort the install if the port is already in use. To check if a port is in use, use this NSIS TCP plugin.

Related

RSYSLOG listening on ephemeral (high) port

I've been poking around the internet trying to get an answer to this one but so far I've only seen it as "normal" behavior.
I have a fedora 29 host configured to send rsyslog messages over the default 514 port. That works as intented and has been for some time now. I had a client notice that the host would "listen" on an ephemeral port that appears to change with each reboot:
ss -tulnp | grep 46852
udp UNCONN 1536 0 0.0.0.0:468520.0.0.0:* users:(("rsyslogd",pid=676,fd=15))
also:
lsof -i :46852 -P
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsyslogd 676 root 15u IPv4 24836 0t0 UDP *:46852
Anyone know why rsyslog is doing this? It appears to be default behavior, and I'm not worried about it as the port can't be hit externally (firewall prohibits it) but just wanted to understand it. I also couldn't find anything in the rsyslog docs that talked about it.
Thanks!
This is just observed behavior I am curious about.
This isn't something that rsyslog is doing, but rather your OS.
Clients are assigned port numbers (random and sequential) by your operating system, as part of the sequence of system calls, that create a network connection. For example TCP and UDP typically use an "ephemeral" port for the client-end of a client–server communication.
These port numbers are - as you said - called "ephemeral" because they are valid only for the life of the connection and have no special significance.
As to why ephemeral ports are used.. I don't know. Maybe someone on ServerFault or Network Engineering can answer this question.
From my understanding ephemeral ports can be used either temporary or private. So if a service (temporarily) needs a port it can use an ephemeral port. After the service has done it's requests and has timed-out for some time, the port is released and can be used by some other service. This way a service doesn't block a port even though it doesn't even use it, or just frequently uses it.

Apache won't bind to ANY port (OS 10048)

I can't get the Apache service to start.
When I try to start it from services I get the following events in event viewer.
The Apache service named reported the following error: (OS
10048)Only one usage of each socket address (protocol/network
address/port) is normally permitted. : AH00072: make_sock: could not
bind to address 0.0.0.0:8090
AH00451: no listening sockets available, shutting down .
AH00015: Unable to open logs
.
I've tried port 80 port 8080 and 8090 and I'm getting the same errors.
I've checked to see if these ports are in use and they are not listed through netstat or through a currports.exe I've used.
I had everything running but I did a SYMLINKS rebuild on apache and mysql and I think I may have done them too quick as I got an error message at the time and mysql and apache stayed down.
I had to re-install the mysql service but the Apache service is going nowhere!!
I have wamp 2.5 with apache 2.4.9 running on windows 2008 R2 Enterprise for the purpose of an office intranet using wordpress.
Help very much appreciated
Cheers
JCro
EDIT Code from Httd.conf. I have just added the lines I've amended #
#
Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen 80
#
# Dynamic Shared Object (DSO) Support
#
#
ServerName localhost:80
HostnameLookups Off
#
Its not too clear what caused this situation but this may get you back up and running.
Start WAMPServer
uninstall the Apache service
wampmanager -> Apache -> Service -> Remove Service
reinstall the Apache service
wampmanager -> Apache -> Service -> Install Service
start Apache
wampmanager -> Apache -> Service -> Start/Resume Service
Now if you ever want to rebuild the Apache SYMLINKS (mysql has non by default) you do this :-
wampmanager -> Apache -> Version -> (click on the current version number)
Then wait a few seconds while WAMPServer rebuilds the SYMLINKS and restarts Apache for you.
Oh then I would put Apache back to Listen on port 80.
RE: Your httpd.conf amendments
This line should be a comment, its an example but not intended to be part of the used parameters in this file
#Listen 12.34.56.78:80
These 2 lines shoud be
# this is for IPV4
Listen 0.0.0.0:80
# This is for IPV6
Listen [::0]:80
These 2 lines look ok as
ServerName localhost:80
HostnameLookups Off
How to see port number in Windows 10?
Open a command prompt window (as Administrator) From "Start\Search box" Enter "cmd" then right-click on "cmd.exe" and select "Run as Administrator"
Enter the following text then hit Enter. netstat -abno. ...
Find the Port that you are listening on under "Local Address"
Look at the process name directly under that.
After you found the PID of the service running on a given your computer, open your task Manager and sort the running processes by PID. find your target PID right click and go to services, right click on the service and stop the service. without starting your apache 2.4 service just start by getting this path "C:\Apache24\bin>httpd -k start" then enter. This is the way I become successful after many ups and down.
OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : AH00072: make_sock: could not bind to address [::]:80 (OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : AH00072: make_sock: could not bind to address 0.0.0.0:80 AH00451: no listening sockets available, shutting down AH00015: Unable to open logs
I was getting the same error when i tried to start the Apache2.4. But when i replaced the Listen 80 with Listen 8080(by going to httpd.conf file placed in conf folder inside Apache24 folder), my problem solved.
you may still get the complaint about port 443. If you look through the httpd.conf, you won’t be able to find 443. But, you will find the following:
Secure (SSL/TLS) connections
Include “conf/extra/httpd-ssl.conf”
Look in the httpd-ssl.conf file, and replace 443 with some other port.
Enjoy!

Can I deploy mysql in the openshift and access from the outter

I create a diy Appliation and add a mysql cartridge and bind it to the port 8080.Is it possible to access outside the network through domain? I have a little idea about the routing
system.
I am not very sure what you want here. But you can use putty in your local machine to connect to Openshift mysql.
Thank you
You can use port forwarding using the 'rhc' command line or using the OpenShift Tooling in JBoss Tools. In both case, you'll have a set of local sockets to connect to, and it will forward commands to the remote 3306 port on your OpenShift gear, so you can run MySQL/SQL commands on your database.

Unable to access port 3306 for mySQL Workbench

I have enabled this through windows Firewall. (I use Avast Free which doesn't have a free firewall) and I have went onto the BT router to port forward this too. Yet I still get system error 10060. I have downloaded PfPortchecker and checked port 3306 and apparently it's still not open.
I am pretty clueless on what to do here, any help is appreciated cheers.
If both MySQL Workbench and your MySQL server run on the same machine then you don't need to open any port on the modem or in the firewall. Focus on problems on your local machine.
First thing to check is: is your server actually running? Is there a service that starts the MySQL server? What setup is that? Did you install the server via the MySQL Windows Installer? If the server is running check the config file if TCP/IP networking is disabled for some weird reason (it should not, but who knows). If that is disabled you can only connect via a named pipe to your server.
Next step is to check is that the user you use to connect is actually allowed to connect from the local machine. Jeremy is right here, it matters if you use localhost or 127.0.0.1, especially if IPv6 is enabled on the box (where localhost resolves to ::1, instead of 127.0.0.1).

CentOS Firewall Issues on GCE

I am trying out a "Hello World" exercise for GCE. First, I went with CentOS Image, added the instance, installed Apache, added the Firewall. All looks good as far as configuration is concerned. When I try to access the web page from outside, it cannot reach the page.
The Local Apache Server is running, from the local instance I can do a curl and all is well.
On the other hand, if I try out the same exact steps with the Debian distribution, everything works smoothly.
I saw another post that mentioned about additional firewall settings but I have not tried that out and I am not sure why it should be done either.
Can anyone explain if the CentOS setup does need additional Firewall settings and what those are?
CentOS defaults to a restrictive operating system level firewall (using iptables), while debian defaults to a permissive one. You can relax the firewall rules on CentOS as well. When running on Compute Engine, the service level firewall will only allow connections from the internet via configured ports.
To relax the CentOS firewall:
$ sudo iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
Then test that your connections work as expected. To save this configuration across system reboots:
$ /sbin/service iptables save
See the IPTables HowTo on the CentOS wiki for more information about working with iptables on CentOS.
You need free the ports in the cloud console.
Watch this video that explain the proccess.
Google Compute Engine Test Drive