Why am I getting “Error socket hang up” response?

I recently got this socket hang up problem. I researched for a few days until I found a solution that worked for me. So, maybe this can help. It worked for me to add the http(s)Agent property with keepAlive: true in creating the http client. Here’s an example of what it might look like: This property is responsible for managing the … Read more

NodeJS – What does “socket hang up” actually mean?

I’m building a web scraper with Node and Cheerio, and for a certain website I’m getting the following error (it only happens on this one website, no others that I try to scrape. It happens at a different location every time, so sometimes it’s url x that throws the error, other times url x is fine and it’s a … Read more

The difference between “require(x)” and “import x”

This simple diagram will help you understand the difference between require and import. Apart from that, You can’t selectively load only the pieces you need with require but with import, you can selectively load only the pieces you need, which can save memory. Loading is synchronous(step by step) for require on the other hand import can be asynchronous(without waiting for previous import) so it can perform a little better … Read more

NodeJS / Express: what is “app.use”?

The app object is instantiated on creation of the Express server. It has a middleware stack that can be customized in app.configure()(this is now deprecated in version 4.x). To setup your middleware, you can invoke app.use(<specific_middleware_layer_here>) for every middleware layer that you want to add (it can be generic to all paths, or triggered only on specific path(s) your server handles), … Read more

Significance of port 3000 in Express apps

3000 is a somewhat arbitrary port number chosen because it allows you to experiment with express without root access (elevated privilege). Ports 80 and 443 are the default HTTP and HTTPS ports but they require elevated privilege in most environments. Using port 3000 in examples also helps indirectly emphasize that you ideally want to put your express app behind nginx or Apache httpd or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)