Hello, When I try to access http://my_ip: 3000, an out-of-time error occurs I’m creating an api rest, but I can not connect to it. My droplet was created with the image UBUNTU-LAMP.
I installed the node with: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs
I created a test file like this:
const http = require (‘http’); const hostname = ‘my_ip’; const port = 3000;
const server = http.createServer ((req, res) => { res.statusCode = 200; res.setHeader (‘Content-Type’, ‘text / plain’); res.end (‘Hello World \ n’); });
server.listen (port, hostname, () => { console.log (Server running at http: // $ {hostname}: $ {port} /); });
Thank you for your attention!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I solved the problem by adding a rule to my Apache configuration file:
–> ProxyPass /voleidobarulho http://localhost:3000
And accessing my Node API by address:
–> http://my_ip/voleidobarulho
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.