Running go webserver on Cloud9 IDE - go

im kinda confused on how to run a go lang webserver on Cloud9IDE.. This is my simple go server i am attempting to run:
https://ide.c9.io/amanuel2/golangpractice
I tried to click run then went to the url it wants me to go but it told me 404 not found... And i also saw this is the output in the command line when i click run on cloud9:
Your code is running at https://golangpractice-amanuel2.c9users.io.
Important: use os.Getenv(PORT) as the port and os.Getenv(IP) as the host in your scripts!
2016/03/14 11:45:51 Listening on port 8080 ...
Please help!

The 404 you're seeing is from line 142 of webserver.go so your app actually is running properly. From your code, it looks like you have a route for /item/name so try going to https://golangpractice-amanuel2.c9users.io/item/name and you'll get something there.
All other routes are giving 404's because of line 142.

Related

How to set port that Laravel runs on in a Portainer Docker Container

First post so apologies if it doesn't look great.
I used to have a Portainer Docker container running Laravel image "bitnami/laravel:latest" on host port 4001, but now i'm trying to re-create it and when accessing http://localhost:4001/
it shows this error:
This page isn’t working localhost didn’t send any data.
ERR_EMPTY_RESPONSE
The container has Manual network port publishing set to Host = 4001 and Container = 4000 and I think the problem is that Laravel isn't actually running on port 4000, so nothing is returned to the webpage.
My notes mention that the port is set in the Command, but they don't say how :-(
enter image description here
So, if anyone can tell me how to set the port via this command then i'd hugely appreciate it!
'/opt/bitnami/scripts/laravel/run.sh'
The run.sh script contains this line:
declare -a start_flags=("artisan" "serve" "--host=0.0.0.0" "--port=${LARAVEL_PORT_NUMBER}")
It looks like it starts Laravel on a port set by this parameter ${LARAVEL_PORT_NUMBER} so I was thinking something like the line below but that didn't work:
'/opt/bitnami/scripts/laravel/run.sh -LARAVEL_PORT_NUMBER 4000'
The container log (below) shows that Laravel starts up ok and it looks like it's saying it's on port 8000 but changing the container in the port publishing to 8000 doesn't work.
Starting Laravel development server: http://0.0.0.0:8000
[Sat Apr 9 20:44:05 2022] PHP 8.1.4 Development Server (http://0.0.0.0:8000) started
Let me know if any more information would help.
[edit]
Just realized I could edit run.sh and hardcode the port, like this:
declare -a start_flags=("artisan" "serve" "--host=0.0.0.0" "--port=4000")
After re-starting the container it's now working and the Laravel page loads in the browser! It's not ideal though so if anyone knows how to pass the port parameter to the bash script then that'd be great :-)
Many thanks!
Rob

Cypress bad gateway

I have started my app locally and reach it fine on http://localhost:3000
But when trying to access it throuhg the cypress tool I get 502 bad gateway. Anyone knows why this differ from it working just fine in Chrome to access it?
Faced the same issue when running Angular app in localhost. App was running in chrome but not in cypress tool giving 502 bad gateway error. I builded the angular app by ng-build command and served using command http-server -p 4200 -c-1 dist/your_poject_name. When running http-server command, got as below:
Starting up http-server, serving dist
Available on:
http://10.132.14.98:4200
http://127.0.0.1:4200
Use the url http://10.132.14.98:4200 in cy.visit and now bad gateway error does not come. The problem is with using 127.0.0.1 or localhost in the url. Anything other than localhost and 127.0.0.1 works. Hope this information helps.

Running dusk tests on Homestead for Windows

I'm using homestead on windows 10 and installed laravel 5.4 when I'm trying to run dusk tests I get the following error:
1) Tests\Feature\ViewProductListingTest::user_can_view_product_listing
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
Failed to connect to localhost port 9515: Connection refused
Has anybody had any luck getting around this?
Thanx.
I encountered this very problem today. I spent like 2 hours researching and finally resolved it by following the steps posted on this comment.
I ran the original basic test and it passed. I'll try to run more complex test and hopefully the solution still works.
It seems to me that the Homestead lacks some necessary software(Chrome, xvfb etc.) to run browser tests with Laravel Dusk. That's what that comment is trying to install.
Hope this helps!
I ran into this issue before and was not able to completely resolve it.
The connection refused error occured for me because the execution scripts for dusk in /vendor/laravel/dusk/bin were not set executable inside Homestead.
So i used a chmod 777 on those scripts.
After that it complained that if couldn't find an executable chrome binary, so i installed google-chrome in Homestead.
After I installed google chrome, the tests ran, but timed out before they could finish which i am researching now.
I ran into the same issue (but I'm on macOS Sierra). If you can, instead of running Dusk from the Homestead VM, run it from your host machine. Just make sure the DB_HOST value in your .env file is set to the hostname you use to access the site in your browser.
So for example, if you configured the Homestead site to be accessible at mycoolsite.app, use that as your DB_HOST value.
I know this is more of a workaround for situations where your host machine might be able to run it OK, but it's working for me at the moment if you can give it a try.

Why won't Apache Server start in MAMP?

I'm trying to view php files locally on my mac.
I'm running Yosemite.
I have MAMP installed on my computer. When I press start the MySQL server starts but Apache doesn't. An error message appears saying 'Error. Apache couldn't be started. Please check your MAMP installation'
I've gone through the internet typing stuff into terminal and changing 'envvars' to '_envvars' but nothing works.
I reinstalled OSX and that worked but when I shut down the computer the problem occurs again.
Can anyone help?
Thanks
Check if you changed the Document Root Location or Renamed it. At least this was my mistake.
MAMP > Preferences > Web Server > Document Root
I didn't get it working with port 8000 or the default 8888, but did get it working with port 80 per the suggestion here:
http://forums.macrumors.com/showthread.php?t=1744944
That didn't work after all, but it didn't error out. However I manually ran the following at the command line (because log file was empty):
sudo /Applications/MAMP/Library/bin/apachectl start
Only to find that after upgrading I was missing the mod_example.so
httpd: Syntax error on line 83 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/Library/modules/mod_example.so into server: dlopen(/Applications/MAMP/Library/modules/mod_example.so, 10): image not found
Copied it from my old install and I was good to go.
If you try to start the server from the terminal, likely that will tell you what is wrong e.g.
sudo /Applications/MAMP/bin/startApache.sh
Password:
(48) Address already in use: make_sock: could not bind to address [::]:8888
(48) Address already in use: make_sock: could not bind to address 0.0.0.0:8888
no listening sockets available, shutting down
Unable to open logs
What you can do in this case, I was inadvertently running a Blockstack browser out of 8888, so changing MAMP to 8887 allowed it to start. [Your mistake might be different.]
Had the same problem, nothing in the logs. After trying the_dillio's suggestion:
sudo /Applications/MAMP/Library/bin/apachectl start
I got an error that pointed back to my vhosts file. It turns out I had an extra /VirtualHost tag. Removed it and it started working again.
i've solved this issue using this command in the terminal :
sudo apachectl stop
I think I've found the solution.
It was the wrong port. I altered the .conf file in the Apache folder. I changed all instances of port 8888 to 8000. When I run MAMP now it all seems to work fine.
Thanks for your help
Also be aware that if you by any chance deleted the folder that was set as Document Root the last time you were using MAMP, you will get this error. Simply open MAMP again, change Document Root to a location that does exist and start the servers.
I received the same error but interestingly it was caused simply because I renamed the root folder and didn't realize it. Sounds like you have a different issue but for anyone else who gets this error message, make sure you haven't renamed the root!
Absolutely bizarre behavior for MAMP PRO (paid license too btw...)
In my case I had to change the location of the log file in order to get it to work...
Click on Mysql icon then the little folder to the right of the path and try changing it to something else.
For MAMP :
You can open the terminal and write:
ps aux | grep mysql
lsof -i
killall -9 mysqld
I hope is good for you!
Bye
I had this experience when upgrading to V4. It tried to used the files from my previous installation and it just never worked. The workaround was to RENAME the original MAMP installation to something different than "MAMP", install brand new version and then copy files you may need like VHOST configs and DATABASES. After all this it worked just fine.
My Apache server problem arose after I enabled SSL. So if this is your case, check your https-ssl.conf file (Applications -> Mamp -> conf -> apache -> extra). The Document Root under the Virtual Host settings had a different file path for htdocs than where it was actually located (easily overlooked). I changed this to "/Applications/MAMP/htdocs" and problem solved. Perhaps also check Document Root in your https.conf file (Applications -> Mamp -> conf -> apache) to see if it has the correct file path to htdocs too.
These are the steps I used to solve this issue.
Checking vcredist that are required and installing them. to check which are the missing vcredist I used a tool called "check_vcredist" from wamp.
I also installed latest Microsoft Visual C++ Redistributable x64.
Doing this steps solved my issue of Apache server not running

Port localhost:3000 does not respond

I use Windows and I ran the .msi.
localhost:3000 does not respond. I activated and rested iis and cannot see anything under 3000. How can I check if the port is active and if anybody s listening? I tried lsof -i in cmd and I get the error "lsof unrecognized batch file"
Also, when I run meteor from the directory with the example or dummy, I do not have anything else following like
..running, port localhost:3000 active
It doesn't look like the command 'meteor' does anything on my machine.
Do I need to put my meteor folder inside the installation one (i.e. C:/Program Files(x86)/meteor)
Since this question was posted, Meteor has gotten an official Windows installer. See if it works now.

Resources