Сервер Node.js внезапно не работает - PullRequest
0 голосов
/ 10 сентября 2018

Вчера все работало нормально, и теперь выдает эту ошибку. Созданный мною API работал нормально, все запросы работали, теперь я понятия не имею, что не так.

Я использовал ng serve для моего Angular app и node app.js для моего API-сервера, и все работало нормально, почему он сейчас не подключается?

Running on port 4000...
(node:13096) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:13096) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connection 0 to localhost:27017 timed out]
    at Pool.<anonymous> (C:\Users\Heiko\Documents\parkingApi\node_modules\mongodb-core\lib\topologies\server.js:564:11)
    at Pool.emit (events.js:182:13)
    at Connection.<anonymous> (C:\Users\Heiko\Documents\parkingApi\node_modules\mongodb-core\lib\connection\pool.js:317:12)
    at Object.onceWrapper (events.js:273:13)
    at Connection.emit (events.js:182:13)
    at Socket.<anonymous> (C:\Users\Heiko\Documents\parkingApi\node_modules\mongodb-core\lib\connection\connection.js:257:10)
    at Object.onceWrapper (events.js:273:13)
    at Socket.emit (events.js:182:13)
    at Socket._onTimeout (net.js:448:8)
    at ontimeout (timers.js:424:11)
    at tryOnTimeout (timers.js:288:5)
    at listOnTimeout (timers.js:251:5)
    at Timer.processTimers (timers.js:211:10)
(node:13096) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13096) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1 Ответ

0 голосов
/ 10 сентября 2018

Журнал ясно показывает, что ваш сервер узла не может подключиться к MongoDB. Причины могут быть любыми. Позвольте мне перечислить несколько возможностей.

  • Сервер MongoDB не работает. Возможно, вам придется перезагрузить тот же
  • Ваш сервер узла может находиться за каким-то брандмауэром, который не разрешает подключение БД к внешним БД.

Вы можете проверить соединение из оболочки, используя:

mongod "mongodb_host_url"

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...