Copy of Amazon EC2 LAMP AMI won't start - amazon-ec2

I have two different AWS accounts. I copied an AMI from one account to another but when I try to start apache,
service httpd start
I get an error.
Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
I have a different elastic IP for the new account, could this be the problem? Where would I have to replace the IP address?

I think it is because you are not a super user.
You can try this:
sudo service httpd start

Related

Troubleshoot localhost / apache - connection refused error on MacOS

I am trying to debug localhost connection refused error. For context, I have a Flask App that I am trying to run locally. I launch the app using gunicorn and notice that it is running on port 8000.
Starting gunicorn 20.1.0
[2022-02-24 05:38:49 -0800] [21269] [INFO] Listening at: http://127.0.0.1:8000 (21269)
[2022-02-24 05:38:49 -0800] [21269] [INFO] Using worker: sync
[2022-02-24 05:38:49 -0800] [21271] [INFO] Booting worker with pid: 21271
I have tried several things including:
restart apache server - sudo apachectl restart
flush dns: sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
Run httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using MacBook-Air-2020.local. Set the 'ServerName' directive globally to suppress this message
(48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
telnet 127.0.0.1
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
When I enter http://127.0.0.1/ in browser, I get
It works!
What else can I try? I am using gunicorn server to deploy / run the App locally.
This did the trick for me:
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache

macos listen tcp 0.0.0.0:80: bind: address already in use

I'm getting:
listen tcp 0.0.0.0:80: bind: address already in use
But I have killed all those httpd daemons:
Why is keep saying that the address already in use?
This is typically when apache is running in the background. You can kill it using this command in your linux machine.
sudo /etc/init.d/apache2 stop

XAMPP apache cannot connect to listening port

I am using xampp on windows 10 and trying to get apache to work. I have set it to listen to port 50563 in the httpd.conf and httpd-ssl.conf, however when I run httpd.exe I get this message:
(OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : AH00072: make_sock: could not bind to address [::]:50563
(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:50563
AH00451: no
listening sockets available, shutting down
AH00015: Unable to open
logs
I have tried running as administrator, I check netstat and that port is free. What should I do?
httpd.conf: https://pastebin.com/NUrWBfRB
httpd-ssl.conf https://pastebin.com/YLLfzEjP
Probably you are trying to listen on 50563 for both http and https? If this is the case you MUST use different ports, maybe use 50563 and 50564 for HTTP and HTTPS respectively.
In the case of multiple Listen directives, Apache will bind to port 80
the first time and then try to bind to port 80 a second time. This
yields a nice "Could not bind to port" error on start up. This
seems to happen with newbies and Debian based distros, where Debian
based distros have Listen 80 defined in ports.conf. Newbies don't
realize this and create another Listen 80 line in *.conf.
From: https://wiki.apache.org/httpd/CommonMisconfigurations

Can not assign EC2 instance Public IP to Mosquitto MQTT broker

I have installed Mosquitto MQTT in one of the EC2 instance(ubuntu) and broker running fine with localhost.
I can able to publish/subscribe in the local machine and as well another EC2 instance (both EC2 in same subnet 172.31.X.X)
Now, i want to connect the broker from a PC outside for (publish/subscribe). So, i tried to configure the broker IP to EC2 instance public IP.
VirtualBox:cat /etc/mosquitto/mosquitto.conf
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
listener 1883 50.24.39.66
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
VirtualBox:
VirtualBox:sudo mosquitto -c /etc/mosquitto/mosquitto.conf
1495801790: mosquitto version 1.4.8 (build date Fri, 19 Feb 2016 12:03:16 +0100) starting
1495801790: Config loaded from /etc/mosquitto/mosquitto.conf.
1495801790: Opening ipv4 listen socket on port 1883.
1495801790: Error: Cannot assign requested address
carun#carun-VirtualBox:~$
But, while restarting the broker am getting the above error "Cannot assign requested address"
Done so far,
Allowed (inboud/outbound) all access to EC2.
Disabled firewall in EC2
-Allowed all security level access to EC2 security group.
But no luck,
So question,
How to assign a EC2 Public IP to the broker?
How can I access MQTT broker out side of world?
Thanks in advance for your help!
Remove the ip address (50.24.39.66) from the end of listener line (or just remove the whole line) to allow mosquitto to bind to all available IP addresses

Apachectl command does not work properly on mac

I started learning Apache server with my macbook, and I typed apachectl on the Terminal.
Unfortunately I could only see the following message.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Marshalls-MacBook-Air.local. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
What do you think is the matter, and how should I fix?
I typed apachectl
You need prefix apachectl with sudo, so:
sudo apachectl start
otherwise the command has no enough privileges to bind into port 80.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name
You need to edit your httpd.conf Apache configuration file and uncomment ServerName line.
To locate the file, run: apachectl -t -D DUMP_INCLUDES first.

Resources