Site the FreeCodeCamp uses to check is offline

Tell us what’s happening:

My code is working perfectly, but the site that FreeCodeCamp uses to check is offline, so the tests never passes. I have already tested my code dozens of times, it works correctly, I have put some console.log() and dicovered that the offline site is:

Your code so far


'use strict';

var express = require('express');
var mongo = require('mongodb');
var mongoose = require('mongoose');
var dns = require('dns')
var cors = require('cors');
var app = express();
var port = process.env.PORT || 3000;


mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

const urlSchema = mongoose.Schema({
  url: {type: String, required: true}

const Url = mongoose.model("Url", urlSchema);


const regEx = /^https?:\/\//


app.use('/public', express.static(process.cwd() + '/public'));

app.get('/', function(req, res){
  res.sendFile(process.cwd() + '/views/index.html');
});"/api/shorturl/new", (req, res) => {


   dns.lookup(req.body.url.replace(regEx, ''), (err) => {
    if (err !== null) {
      res.json({"error": "invalid url"})
    } else {
      const url = new Url({url: req.body.url});, result) => {
        if (err) return console.log(err);
        const obj = {"original_url": result.url, "short_url": result._id}

app.get("/api/shorturl/:id", (req, res) => {
  Url.findById(, (err, result) => {
    if (err) return res.status(500).json({"error": "invalid url"})
    if (!regEx.test(result.url)) {
      result.url = `http://${result.url}`;

app.listen(port, () => {
  console.log('Node.js listening ...');

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36.

Challenge: URL Shortener Microservice

Link to the challenge:

1 Like

Hello and welcome to the freeCodeCamp community~!

I tested the challenge suite against the example project and it works as intended. As a point of curiosity, you’ve shared code (and the link) for the URL shortener, but the error you’ve shared is for the Timestamp Microservice. Can you verify that you are submitting the correct project on the correct page? :slightly_smiling_face:

I discovered now that the problem isn’t FCC, I’m trying to discover why, but, the dns.lookup() is throwing an error when there are “/” in the link, like: works, but, doesn’t

Hello there,

The challenge has been updated, and no longer requires the submitted URL to be valid. So, you are welcome to use dns.lookup, but the requirement has been removed.

That being said, I suggest you take another look at the docs for dns.lookup, because you are passing it values which it does not work with:

dns.lookup(req.body.url.replace(regEx, ''),

Hope this helps

PS. for future posts, it is much easier to work with code, if you provide a link to your project.

Actually, it’s still necessary to validate the URL.
I found a solution, I imported the module “url”, with it, I could use the DNS to check just the hostname, without the protocol and subdirectories.