How to open a web server port on EC2 instance - amazon-ec2

I'm running a CherryPy web server at 0.0.0.0:8787 on an EC2 instance.
I can connect to the web server via local wget on the EC2 machine, but I can't reach the instance from my own remote machine (I connect to EC2 via ssh).
Do I need to open up port 8787 to access the web server remotely? If so, how can this be done? Also, can I use the public IP of the EC2 instance for this?

Follow the steps that are described on this answer just instead of using the drop down, type the port (8787) in "port range" an then "Add rule".
Go to the "Network & Security" -> Security Group settings in the left hand navigation
Find the Security Group that your instance is apart of
Click on Inbound Rules
Use the drop down and add HTTP (port 80)
Click Apply and enjoy

You need to open TCP port 8787 in the ec2 Security Group. Also need to open the same port on the EC2 instance's firewall.

You need to configure the security group as stated by cyraxjoe.
Along with that you also need to open System port.
Steps to open port in windows :-
On the Start menu, click Run, type WF.msc, and then click OK.
In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.
In the Rule Type dialog box, select Port, and then click Next.
In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number , such as 8787 for the default instance. Click Next.
In the Action dialog box, select Allow the connection, and then click Next.
In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect , and then click Next.
In the Name dialog box, type a name and description for this rule, and then click Finish.
Ref:- Microsoft Docs for port Opening

You just need to run command
sudo iptables -A INPUT -p tcp --dport <port_number> -j ACCEPT
You will be allow to access port in AWS Ubuntu

Related

Windows Azure Virtual Machine - Opening a port

I am trying to open a port in a Windows Azure virtual machine. I have a game listening on that port, and I am able to access it via localhost, so the game is running.
I have also opened the port in the firewall and created an endpoint in the virtual machine, but the port doesn't seem to be open to the outside world. I have tried accessing it both via the IP address and the DNS with the same results.
Is there anything else I should do? I have looked up several tutorials online and can't figure out what I am doing wrong.
this has changed to this
I would recommend ignoring 100% of what is on google at the moment
Irina, make sure you have configured your endpoint properly by setting the private and public port. Here's a documentation that explains the steps to accomplish this...
http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/
It's easy via Azure CLI, for example , open port 80
$ az vm open-port -g MyResourceGroup -n MyVm --port 80
Open multiple ports at the same time
az vm open-port -g MyResourceGroup -n MyVm --port 80-100 --priority 100
Open all..
az vm open-port -g MyResourceGroup -n MyVm --port '*'
Pay special attention to this parameter,Must be unique for each rule
--priority : Rule priority, between 100 (highest priority) and 4096 (lowest priority).
Must be unique for each rule in the collection. Default: 900.
This is a two step process:
Configure the port rule in the Azure Portal (No need of any restarts. The effect takes place in a few minutes.)
Here are the steps (at the time of writing): Click on the VM -> Click on 'Networking' -> Click 'Allow inbound port rule'
Configure the port rule in the VM's own Firewall - this depends on the Operating System your VM has got (OR disable this firewall)
Here are the steps for Windows 10:
Open 'Windows Firewall with Advanced Security' Desktop App -> Click on 'Inbound Rules' on the left panel -> Click on 'New Rule' in the Actions panel on the right. The following screenshots explain the rest.
Now the application listening to the port can be reached over the internet.
For future reference, if you're trying to listen to 3000 or that range it simply does not work.
Go to the 8080's range, make the inbound rule and you're up and running.
Probably this is the latest solution at a time of writing this answer:
You need to create a Network Security Group (or use an existing one). The easiest way is to search for Network Security Groups in the search resources bar. If there is an existing NSG, click on it and find inbound security rules from the settings. Then add an inbound rule with your desired port.For example, I opened port 8080 on my VM with settings shown in picture below.
More info: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-nsg-quickstart-portal/
In addition to described, you may need to create inbound rule in VM firewall. The settings in portal create forwarding from public IP towards VM. VM itself should allow applications to listen on the port.
This may explain why this didn't work for Irina on some ports and worked on other ports.
Check the Windows firewall on the VM also. If port 8080 is not added in firewall inbound rules, then make sure to add a new inbound rule to allow access to port 8080. (Remotely login to your VM. Windows Defender Firewall -> Advanced Settings)
Source port ranges: * (allows any source port)
After you've created a VM that's configured to serve web requests on the standard TCP port 80, you can:
Create a network security group.
Create an inbound security rule allowing traffic and assign values to the following settings:
- Destination port ranges: 80
- Source port ranges: * (allows any source port)
- Priority value: Enter a value that is less than 65,500 and higher in
priority than the default catch-all deny inbound rule.
Associate the network security group with the VM network interface or subnet.
it's assumed you've already started the appropriate services and opened any OS firewall rules on the VM
for other example : port ranges: 2022-2023

Windows 8 can not access the site of wamp from other computer on local network

I have installed
windows 8
Wamp server
here i have added my local site but as you know i am able to access
http://localhost/test
from the this computer where i have installed wamp the ip address is like=10.0.1.1
now from thei computer i can acess
http://10.0.1.1
but from other computer i can't access this 10.0.1.1 but it's connection is fine i can ping it
thanks
The most likely cause is you're being blocked by the firewall, make sure to add an exception to your firewall exception list to allow the connection.
i solved the problem by disabling the firewall for port 80.
Go to Search on right side of windows.
search "firewall".
open the "firewall with advanced".
go to inbound rules.
click on "new rule".
select the "Port" option.
click "next"
select "TCP" option.
select "Specific local ports:".
type "80" in next text box
click next.
select the "Allow the connection".
click "next".
click "next".
give the name "Port 80 Allow Rule".
click "next".
Note: this is not a secure way. delete this newly created rule when you complete your work.

Configure firewall to enable XAMPP working over LAN

When I turn off the firewall, I can access my XAMPP website through other LAN computers. When I turn on firewall then I cannot connect to the machine anymore. Could someone tell me what's happening?
my os is windows xp. thanks.
Go to Control panel - > go to Windows Firewall -> then Advance Settings ->
Click Inbound Rules
right Click the inbound rules and select "New Rule..."
select option port and click next
select all local ports or your port number for apache server. and click next
select option allow the connection and click next
next
Give name Allow All Local Port For Xampp
Try This, I hope it will Work for you.
I understand this is an old question and related to Windows XP but now for users using current OS like Windows 10 the option that worked for me is that Inbound Rules Profile could be set to Public for Apache Http Server which is set to Private by default.
The profile could be set in 'Advanced' tab of Apache Http Server Inbound Rules properties as shown below (Properties Dialog box could be opened by Right Clicking on Apache Http Server and select Properties):
Well , first of all, firewall on host is blocking your connection. If you are using Windows firewall or any other firewall You need to make an excaption rule for XAMPP.
So, on computer where is web site hosted go to Control panel-> Windows Firewall and uncheck Don't allow exceptions checkbox. Now open Exceptions tab and click on a button Add program and locate Xampp and Apache. Add them to firewall exception rule.
Maybe you should do this test on some Virtual Machine (VMware, Virtualbox..etc) becouse opening ports and adding exceptions if this machine is connected to Internet is not secure.
In my case, (windows 10 and xampp v3.3.2)
1. Open Control Panel
2. Search for windows fire wall
3. Click Advance setting
4. Click inbound rules
5. Allow all blocked rule in name Apache HTTP Server and mysqld

windows server 2008 r2 - can't get apache to run on port 80

I have a rackspace cloud server running windows server 2008 r2. I've uninstalled IIS because I want to install Apache.
I've installed Apache but it fails everytime i try to run it when i listen to port 80.
I've run the command netstat -aon|finderstr "80" and i see the following:
C:\Users\Administrator>netstat -aon|findstr "80"
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 10.180.15.249:139 0.0.0.0:0 LISTENING 4
TCP [::]:80 [::]:0 LISTENING 4
UDP 10.180.15.249:137 : 4
UDP 10.180.15.249:138 : 4
So what are these things running on port 80 and why can't i get apache to start? Is there an alternative port for to run apache under that will work just as well as 80?
To enable port 80 on Windows Server 2008 R2:
NOTE: This assumes that IIS is not installed. I added this firewall rule to enable Apache to accept connections on port 80.
Click Start->Control Panel->Windows Firewall
Click "Advanced Settings" in the left panel of Windows Firewall
Click "Inbound rules" in the left panel of Advanced Settings
Click "New Rule..." in right "Actions" panel
Select "Port" and click "Next>"
Select "TCP", then "Specific local ports:" (should already be selected)
Type 80 in the box (just the number) and click "Next>"
Select "Allow the connection" and click "Next>"
Leave all profiles checked and click "Next>"
Enter a name and click "Finish".
Your server should now be able to accept connections on port 80.
On a Windows server running MSSQL, disabling MSSQL ReportServer (display name: SQL Server Reporting Services (MSSQLSERVER)) services and World Wide Web Publishing services, resolved the problem for me. No need to fiddle with firewall settings or changing default port configurations.
I am running a windows 2008 r2 with IIS and sql server. I added an additional IP address to run apache and configured IIS to bind to one of the IP addresses. I ran into the same problem and found suggestions about disabling SQL reporting services and WinRM. These solutions did not work for me.
There are many different services that can use the http server api(http.sys) and will then show up simply as pid 4.
I found the answer at the link below. The essence of the link is to go to a command prompt.
Type netsh press enter.
Type http and press enter.
add iplisten ipaddress=x.x.x.x
http://msdn.microsoft.com/en-us/library/cc307219(v=vs.85).aspx
There is also a method to disable http.sys in the registry but I do not know what the ramifications of that might be.
I hope this helps someone else so they don't waste as much time as I did trying to find the resolution.
I find that I can successfully add the firewall rules to make my own server run on port 80 within the vshost visual studio debug environment but when running as a service it only works on local host from the machine and not from external hosts.
Very frustrating. Seems that there are possible conditions in the firewall which are not exposed in the Windows Firewall configuration interface very clearly.
With IIS installed you need to change bindings on web sites in IIS so that none uses "all available addresses":80 binding. Either change the ports, or change listening IP addresses.

EC2 Network Error : Connection timeout

I created an EC2 micro instance of Linux and launched it, created a keypair and all the beginning stuff specified in this video:
http://www.youtube.com/watch?v=hJRSti6DsJg
But when I connect to my instance with PUTTY terminal, it will not connect to my EC2 instance.
I have specified the correct instance Public DNS and private key which I created with the PUTTY key generator.
I get this error:
Network Error : Connection timeout
You simply need to add an ssh rule for inbound connections to you ec2 instance in the ec2 management console.
Go to ec2 console
Click Instances on Left
Select your instance
In the Description tab, locate Security Groups and click the available group link
Click edit button on Inbound tab
Click Add Rule and select SSH for type, Port Range 22, and Source Anywhere
Connect with putty :)
Are you sure you've enabled SSH access in the firewall settings of your instance?
Can you connect with PUTTY to other machines? Perhaps your local firewall is blocking SSH connections.
Also, you cannot simply use a private key you generated with PUTTY - you'll have to create one using the AWS web interface, assign it to your EC2 instance, download it to your local computer and instruct PUTTY to use this when connecting to your EC2 instance.
Having successfully connected in the past, I got this error after shutting down my instance and starting it again.
Apparently the Public DNS changes after you shut it down and start it again, so I had to replace the DNS string in PuTTY before it could find my instance to connect with it on port 22.
This error may occur when you enable ufw and reboot your instance. First you have to add 22/tcp before enabling ufw. Following is the command
$ ufw allow 22/tcp
If you already made the mistake. Then follow the following guide
Start a recovery instance.
Stop the blocked instance (DON'T TERMINATE)
Detach the blocked instance volume.
Attach Blocked volume to the recovery instance.
Log to the recovery instance(Newly Launched) via ssh/putty
Type sudo lsblk to display attached volumes
Verify the name of the Blocked volume. Generally start with /dev/xvdf.
Mount blocked volume.
$ sudo mount /dev/xvdf1 /mnt
$ cd /mnt/etc/ufw
Open ufw configuration file
$ sudo vi ufw.conf
Enable insert mode by pressing i in vi editor
Update ENABLED=yes to ENABLED=no
ClickESC and type :wq to update the file.
Verify the file contents. where update to ENABLED=yes -> ENABLED=no
$ sudo cat ufw.conf
Remove the mounted blocked volume from recovery instance
$ cd ~
$ sudo umount /mnt
Now detach blocked install volume from recovery instance and re-attach it to the original instance as /dev/sda1.
Finally, Start the blocked instance. Here's you will able to access your instance. If you enable ufw again don't forget to allow 22/tcp.
One more thing to remember when using putty to connect to, add security setting to accept ssh connection.
If you take default security group
I faced a similar issue.
Reason : Since in my Security Group, Inbound traffic to Port 22 was set to MyIP, now since every time I connected to Internet, I got assigned a different IP, while in our Security Group the Inbound Traffic to SSH was expected to come from previous IP only.
Solution : Edit the Security Group, and either make the Inbound Traffic to Port 22 as 'Anywhere'(not recommended) or again click the myIP(which will give the current IP assigned to you). Problem will be fixed.
I'm also facing the same Network Error : Connection timeout issue after keep all thing at correct place.
But in my case, internet gateway(igw) is not working so you guys also check default VPC configuration for troubleshooting.
This error is generally occurred because server not responding means source have not clear path to connect to you server even you put SSH 22 port in SG.
I faced this issue. Possible cases are
Make sure to open port number-22(ssh) in Inbound rule of Security group
Make sure to use correct .ppk file
Check Network settings. The VPC in which you have launched an instance, may not have
attached to Internet gateway. This happens when you accidentally delete the default
Internet-
gateway.
a) Create Internet gateway and attach to the mentioned VPC
b) In route table->route, add Internet gateway with (0.0.0.0/0)
This should fix the problem. :-)
You simply need to add an ssh rule for inbound connections to you ec2 instance.
Go to ec2 console Security Groups
Select your Security Groups
Click edit button on Inbound tab
Click Add Rule and select SSH for type, Port Range 22, and Source Anywhere or My IP
Click save rules button
Now connect it's working

Resources