               (progn
                 (set-variable 'ycmd--server-actual-port
                               (string-to-number (match-string 1 proc-output)))
-                (setq cont nil)))
+                (setq cont nil)
+                (ycmd--with-all-ycmd-buffers (ycmd--report-status 'unparsed))))
              (t
               ;; timeout after specified period
               (when (< (/ ycmd-startup-timeout 1000) (- (float-time) start-time))
-                (with-current-buffer orig-buff
-                  (ycmd--report-status 'errored))
-                (error "Server timeout"))))))))))
+                (ycmd--with-all-ycmd-buffers (ycmd--report-status 'errored))
+                (when (ycmd-running?) (ycmd-close))
+                (error "ERROR: Ycmd server timeout"))))))))))
 
 (defun ycmd--column-in-bytes ()
   "Calculate column offset in bytes for the current position and buffer."

    (setq ycmd--on-focus-timer
          (run-at-time 1.0 nil #'ycmd--on-unparsed-buffer-focus))))

(defun ycmd--teardown ()
  "Teardown ycmd in current buffer."
  (ycmd--kill-timer ycmd--notification-timer)

  (ycmd--kill-timer ycmd--keepalive-timer))

(defun ycmd-running? ()
  "Return t if a ycmd server is already running."
  (and (get-process ycmd--server-process) t))

(defun ycmd--keepalive ()
  "Sends an unspecified message to the server.
