Node.js application wont start on my public IP - reactjs

I'm SSHing into a linux shell for a school project. Right now, we're trying to set up a react app for a web frontend. We were able to run the app on localhost easily enough, and all of the functionality seems to be good, but I can't figure out how to get this hosted on the public IP of the computer. We've been using yarn to do all of this, though i've tried other things, so here's some cli output.
path/to/thing# yarn start
yarn run v1.22.5
$ react-scripts start
Attempting to bind to HOST environment variable: public.facing.ip.address //This is a website name
If this was unintentional, check that you haven't mistakenly set it in your shell.
Learn more here: //There was a link here but SO formatting wouln't let me keep it.
Could not find an open port at public.facing.ip.address.
Network error message: listen EADDRNOTAVAIL: address not available public.facing.ip.address //numeric
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
root#computer:path/to/thing#
When I run hostname -I, public.facing.ip.address does not appear at all. So that seems like the obvious issue. The catch here is that we are also running jenkins on a separate port of public.facing.ip.address from this same computer. That was much easier to set up, it just came as something I could start as a service using 'systemctl start jenkins' and up it went onto the public facing IP. I set all that up and I can access it just fine, etc. The best I can do with this is modify the HOST variable either in the terminal or the .env file, then yarn starts a development server on localhost (which I can't access since I'm on a different network SSHing into this computer)
How do I make yarn host our webapp on the public facing IP?

open your router page, there should be dmz host option somewhere, point it to your local ip address

My networking inexperience was the culprit. Instead of using HOST=path.to.public.ip, the solution was to use HOST=0.0.0.0.

Related

Expo, java.net.SocketTimeoutException:failed to connect

am new to React native Expo I need to add some new modules on my project. "expo": "33.0.0", "react": "16.8.3", whenever I try to run my project am getting Error am not able to run the project. I tried all way to run the project like set REACT_NATIVE_PACKAGER_HOSTNAME='192.168.0.102', firewall off, allowed inbound 19000 port etc. but am getting error.
when I enter expo start -c
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo install [package-name ...]
Starting Metro Bundler on port 19001.
Your JavaScript transform cache is empty, rebuilding (this may take a minute).
Your native app is running at exp9c305c55e38f4d0e856f59397620314e://192.168.0.101:19000
Logs for your project will appear below. Press Ctrl+C to exit.
then my laptop and mobile is connected with same network and same IP but am getting error and i don't know the port 19000 is different from my wifi
Uncaught Error:java.net.SocketTimeoutException:failed to connect to/192.168.1.20(port 19000)from/192.168.0.102(port 49615) after 10000ms
Please give some solution for it.
It's failing because port 19000 is not open in your firewall. If you use linux OS open this port by running:
sudo ufw allow 19000/tcp
enter image description hereFirst Check are you in tunnel connection?
If you are in tunnel connection then
First : ipconfig
then : set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.103 (IPv4 Address)
then:npm start
It worked for me. Hopefully it will help.
I resolved this by changing the network profile on the connected wifi from private to public.
Expo Error Fix

How to see console.logs of a running nodeJs application on ubuntu 18 EC2 instance?

I am new to the node world. I created a node js rest API. When I run npm start in my local machine or in the terminal for the first time, I can see console.log() in my terminal. Now, I am running the same application on an AWS Ec2 instance with Ubuntu as os. I run npm start and serve my app on port 80. I do this via ssh and after running my server I close the ssh connection. But when I reconnect via ssh, I want to see those console.log() messages in my terminal for some purpose.
I completely understand that logging messages in the terminal is not a good idea and there can be so many alternatives. Just want to know how to access the same terminal window/result as we see when I start my application.
if you are using pm2, you can try "pm2 logs"
So Nodemon won't work well in a production server or in any instance where you need to have the app going by itself.
Nodemon is a dev tool to enable you to restart your server during development. In a "real" vps you need to place the process in the background or it will be automatically killed when the connection times out.
Check out this YT series for a correct deploy architecture in an NGINX server with the use of pm2 and NGINX on a Red Hat server, I've personally used it more than once:
https://www.youtube.com/playlist?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

Project inside webapp tomcat8 does not run in webpage

I am trying to run my application using tomcat8 inside the Apache2 virtual machine, using MacOS.
The IP address is: http://143.167.11.2:8080
and this the view when I run the link on the browser:
I have installed tomcat8 inside this apache2 VM using: apt-get install tomcat8 by following this instruction: https://www.linode.com/docs/development/frameworks/apache-tomcat-on-ubuntu-16-04/
When I run this address http://143.167.11.2:8080 the result is the same, it just shows this same picture . It does not show the tomcat home page.
I have tried to run this: ./startup.sh and inside the terminal and it started.
But when I run the linked address http://143.167.11.2:8080 the result is same, it shows apache home page.
I tried to put my project inside /var/lib/tomcat8/webapps and then tried to run: http://143.167.11.2:8080/visualisation-dataproject.
But the result like below:
Any idea how can I run my project (that I put on the webapps folder) on the web browser?
Apache2 is usually use for PHP project. Tomcat is usually for java project. There are some possibility why you can not run tomcat on the web browser. One of the reason is you have not install tomcat8 properly. Even you have install it, you should check it really work or not. If it work on the VM, maybe the problem when you set the port for tomcat in server.xml.
To check server.xml, try : sudo nano /etc/tomcat8/server.xml, and find <Connector port="8080" protocol="HTTP/1.1 ... line.
And try to change the port 8080 to another port e.g: 8081. Why? to prevent tomcat8 server running with same port with another server such as apache2.
After that try the step on this link: https://askubuntu.com/a/434085/856656 it should work.

Can't connect to localhost:8080 when trying to run Google App Engine program

I'm trying to run the Google App Engine Python 2.7 Hello World program and view it in a browser via Google App Engine Launcher. I followed the install and program instructions to the letter. I copied and pasted the code in the instructions to the helloworld.py file and app.yam1 and verified that they are correct and in the directory listed as the application directory. I hit run on the launcher and it runs with no errors, although I get no sign that is has completed (orange clock symbol next to app name). I get the following from the logs:
Running dev_appserver with the following flags: --skip_sdk_update_check=yes --port=8080 --admin_port=8000 Python command: /opt/local/bin/python2.7
When I try to open in the browser via the GAE Launcher, the 'browse' icon is grayed out and the browser won't open. I tried opening localhost:8080 in Firefox and Chrome as the tutorial suggests, but I get unable to connect errors from both.
How can I view Hello World in a browser? Is there some configuration I need to make on my machine?
I had the same problem. This seemed to fix it:
cd to google_appengine, run
python dev_appserver.py --port=8080 --host=127.0.0.1 /path/to/application
at this point there is a prompt to allow updates on running, I said Yes.
At this point the app was running as it should, also when I quit this and went in using the launcher again, that worked too.
I have to manually start python and make it point to my app folder, for instance in a command line window on Windows I am using python. I installed python in C:\Python27 and my sample app is in c:\GoogleApps\guestbook
C:\Python27>dev_appserver.py c:\GoogleApps\guestbook
and then I can start my app in the Google App Engine Launcher and hit localhost 8080
How about specifying --host argument? You can find it at the bottom of following doc.
https://developers.google.com/appengine/docs/python/tools/devserver
This might be a little late. But still someone might find it useful.
When ever you go and try changing the port number from 8080 to something else, it will not get updated. So the best option is:
Go to your user directory: eg: C:\Username
There will be a Google folder. Go inside
Open the file google_appengine_projects.ini
Change your port number from 8080 to whatever you like 8081
Save it and close the file.
Launch the GAE Launcher again and you will find the changes reflected and the app runs without issues.
7: Access the application using: http://localhost:NewPort/
This can be used to change ports both run port and admin port for your individual projects running locally.
Hope this helps!
The 8080 portion of your url is a port number. Firefox disables visiting url's of other ports by default. You have to enable them by doing the following: http://blog.christoffer.me/post/2012-02-20-how-to-remove-firefoxs-this-address-is-restricted/
Paraphrasing that website:
Open firefox and visit about:conf
In the Filter box, type in network.security.ports.banned.override
If you can't find such a preference, right click to open up the pop-up menu and pick New and then String
As preference name type network.security.ports.banned.override and 8080 as the value.
Done!
It's likely if this continues to not work that your browser is behaving properly (8080 is a fairly standard port). That means that its a problem with the server and we'd have to do some more debugging.

deploying gae to development server stopped working

I'm working through a test GAE Java project which was working fine but I decided to look at adding GWT to the same project. I then decided to stick with the GAE stuff I was learning and decided to remove GWT. The problem is I can't now deploy to the development server as it gives the following in the Eclipse console pane. Anyone know please how I can reset appropriate settings to how my project had them originally?
terminated test [Web Application] C:\Program
Files\Java\jdk1.6.0_37\bin\javaw.exe Usage:
[options]
Options: --help, -h Show this help message and exit.
--server=SERVER The server to use to determine the latest -s SERVER SDK version. --address=ADDRESS The address of the interface on the local machine -a ADDRESS
to bind to (or 0.0.0.0 for all interfaces). --port=PORT
The port number to bind to on the local machine. -p PORT
--sdk_root=DIR Overrides where the SDK is located. --disable_update_check Disable the check for newer SDK versions. --generated_dir=DIR Set the directory where generated files are created. --jvm_flag=FLAG Pass FLAG as a JVM argument. May
be repeated to
supply multiple flags.
I seem to have found my own answer through setting up a new dummy gae project and having a poke around, found that the 'Run As' > 'Run Configurations...' > '(x)= Arguments' > 'Program arguments' had an additional port defined prior to the rest of the argument beginning '--port=8888'. I removed the mention of '-codeServerPort 9997 ' and it now deploys to dev server and appears to be working as before.
eg
new dummy project: --port=8888 "C:\Users\tech1\SSD Storage\Eclipse Projects\workspace\dummy\war"
project that wouldn't deploy to dev server: -codeServerPort 9997 --port=8888 "C:\Users\tech1\SSD Storage\Eclipse Projects\workspace\test\war"
I faced the same issue and you know what, Workaround is just pretty simple.
I created one new appengine project with only one jsp in WAR and 'Run As' > 'Run Configurations...' >Server Tab -> Unchecked then checked Run Built-In server and then checked Automatically select any port.
Server started ..on some fishy 25334 port..i stopped that using red button on Console Terminal.
then i changed it back to 8888 and WHOA project Ran.... :)
Then i did the same with old project. deleted this new one and all is working as expected.

Resources